kopia lustrzana https://github.com/cirospaciari/socketify.py
add mutations to graphiql
rodzic
e000162277
commit
29cafd0414
|
@ -21,5 +21,7 @@ class Query:
|
||||||
app = App()
|
app = App()
|
||||||
app.get("/", lambda res, req: res.end(strawberry.utils.graphiql.get_graphiql_html()))
|
app.get("/", lambda res, req: res.end(strawberry.utils.graphiql.get_graphiql_html()))
|
||||||
app.post("/", graphiql_from(Query))
|
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.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port))
|
||||||
app.run()
|
app.run()
|
|
@ -1,8 +1,11 @@
|
||||||
import strawberry
|
import strawberry
|
||||||
import strawberry.utils.graphiql
|
import strawberry.utils.graphiql
|
||||||
|
|
||||||
def graphiql_from(Query):
|
def graphiql_from(Query, Mutation=None):
|
||||||
schema = strawberry.Schema(Query)
|
if Mutation:
|
||||||
|
schema = strawberry.Schema(query=Query, mutation=Mutation)
|
||||||
|
else:
|
||||||
|
schema = strawberry.Schema(Query)
|
||||||
|
|
||||||
async def post(res, req):
|
async def post(res, req):
|
||||||
# we can pass whatever we want to context, query, headers or params, cookies etc
|
# we can pass whatever we want to context, query, headers or params, cookies etc
|
||||||
|
|
Ładowanie…
Reference in New Issue