mirror of
https://github.com/fastapi/fastapi.git
synced 2026-03-04 06:58:42 -05:00
✨ Add docs for GraphQL (#48)
This commit is contained in:
committed by
GitHub
parent
bf53518141
commit
984dd71d13
14
docs/src/graphql/tutorial001.py
Normal file
14
docs/src/graphql/tutorial001.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import graphene
|
||||
from fastapi import FastAPI
|
||||
from starlette.graphql import GraphQLApp
|
||||
|
||||
|
||||
class Query(graphene.ObjectType):
|
||||
hello = graphene.String(name=graphene.String(default_value="stranger"))
|
||||
|
||||
def resolve_hello(self, info, name):
|
||||
return "Hello " + name
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
app.add_route("/", GraphQLApp(schema=graphene.Schema(query=Query)))
|
||||
Reference in New Issue
Block a user