]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
✏️ Update Strawberry integration docs (#13155)
authorKinuax <kinuax@users.noreply.github.com>
Mon, 6 Jan 2025 11:24:17 +0000 (12:24 +0100)
committerGitHub <noreply@github.com>
Mon, 6 Jan 2025 11:24:17 +0000 (11:24 +0000)
docs/en/docs/how-to/graphql.md
docs_src/graphql/tutorial001.py

index a6219e481d6506a8626ea1d14b77a26b51d11e21..3610107360acb774c600b83bd9edf0fdf60ddab1 100644 (file)
@@ -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:
 
-{* ../../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>.
 
index 3b4ca99cf6b50532429f8db0813b125bb6482890..e92b2d71c418457f58ea659920d34104bc7a1fe2 100644 (file)
@@ -1,6 +1,6 @@
 import strawberry
 from fastapi import FastAPI
-from strawberry.asgi import GraphQL
+from strawberry.fastapi import GraphQLRouter
 
 
 @strawberry.type
@@ -19,8 +19,7 @@ class Query:
 schema = strawberry.Schema(query=Query)
 
 
-graphql_app = GraphQL(schema)
+graphql_app = GraphQLRouter(schema)
 
 app = FastAPI()
-app.add_route("/graphql", graphql_app)
-app.add_websocket_route("/graphql", graphql_app)
+app.include_router(graphql_app, prefix="/graphql")