GraphQL: Re-add extension and dependencies (2024)

This commit is contained in:
Taoufik
2024-10-26 03:49:18 +02:00
committed by Andreas Motl
parent 3aa21eed08
commit a698eaaab3
5 changed files with 269 additions and 3 deletions
+5 -2
View File
@@ -34,14 +34,17 @@ Here, you can spawn off a background thread to run any function, out-of-request:
GraphQL
-------
responder supports GraphQL::
Responder supports GraphQL, a query language for APIs that enables clients to
request exactly the data they need::
pip install 'responder[graphql]'
For more information about GraphQL, visit https://graphql.org/.
Serve a GraphQL API::
import graphene
from responder.ext.graphql import GraphQLView
class Query(graphene.ObjectType):
hello = graphene.String(name=graphene.String(default_value="stranger"))
@@ -50,7 +53,7 @@ Serve a GraphQL API::
return f"Hello {name}"
schema = graphene.Schema(query=Query)
view = responder.ext.GraphQLView(api=api, schema=schema)
view = GraphQLView(api=api, schema=schema)
api.add_route("/graph", view)