mirror of https://github.com/tiangolo/fastapi.git
✏️ Update Strawberry integration docs (#13155)
This commit is contained in:
parent
6e60d0a056
commit
b0e70cb37e
|
|
@ -35,7 +35,7 @@ Depending on your use case, you might prefer to use a different library, but if
|
||||||
|
|
||||||
Here's a small preview of how you could integrate Strawberry with FastAPI:
|
Here's a small preview of how you could integrate Strawberry with FastAPI:
|
||||||
|
|
||||||
{* ../../docs_src/graphql/tutorial001.py hl[3,22,25:26] *}
|
{* ../../docs_src/graphql/tutorial001.py hl[3,22,25] *}
|
||||||
|
|
||||||
You can learn more about Strawberry in the <a href="https://strawberry.rocks/" class="external-link" target="_blank">Strawberry documentation</a>.
|
You can learn more about Strawberry in the <a href="https://strawberry.rocks/" class="external-link" target="_blank">Strawberry documentation</a>.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import strawberry
|
import strawberry
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from strawberry.asgi import GraphQL
|
from strawberry.fastapi import GraphQLRouter
|
||||||
|
|
||||||
|
|
||||||
@strawberry.type
|
@strawberry.type
|
||||||
|
|
@ -19,8 +19,7 @@ class Query:
|
||||||
schema = strawberry.Schema(query=Query)
|
schema = strawberry.Schema(query=Query)
|
||||||
|
|
||||||
|
|
||||||
graphql_app = GraphQL(schema)
|
graphql_app = GraphQLRouter(schema)
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
app.add_route("/graphql", graphql_app)
|
app.include_router(graphql_app, prefix="/graphql")
|
||||||
app.add_websocket_route("/graphql", graphql_app)
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue