diff --git a/examples/graphiql.py b/examples/graphiql.py index 302d193..8363203 100644 --- a/examples/graphiql.py +++ b/examples/graphiql.py @@ -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() \ No newline at end of file diff --git a/examples/helpers/graphiql.py b/examples/helpers/graphiql.py index e6cefc2..bce52eb 100644 --- a/examples/helpers/graphiql.py +++ b/examples/helpers/graphiql.py @@ -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