add mutations to graphiql

pull/39/head
Ciro 2022-11-15 10:30:01 -03:00
rodzic e000162277
commit 29cafd0414
2 zmienionych plików z 7 dodań i 2 usunięć

Wyświetl plik

@ -21,5 +21,7 @@ class Query:
app = App()
app.get("/", lambda res, req: res.end(strawberry.utils.graphiql.get_graphiql_html()))
app.post("/", graphiql_from(Query))
# you can also pass an Mutation as second parameter
# app.post("/", graphiql_from(Query, Mutation))
app.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port))
app.run()

Wyświetl plik

@ -1,8 +1,11 @@
import strawberry
import strawberry.utils.graphiql
def graphiql_from(Query):
schema = strawberry.Schema(Query)
def graphiql_from(Query, Mutation=None):
if Mutation:
schema = strawberry.Schema(query=Query, mutation=Mutation)
else:
schema = strawberry.Schema(Query)
async def post(res, req):
# we can pass whatever we want to context, query, headers or params, cookies etc