Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/en/docs/how-to/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>.

Expand Down
7 changes: 3 additions & 4 deletions docs_src/graphql/tutorial001.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import strawberry
from fastapi import FastAPI
from strawberry.asgi import GraphQL
from strawberry.fastapi import GraphQLRouter


@strawberry.type
Expand All @@ -19,8 +19,7 @@ def user(self) -> User:
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")