Sync fastapi docs from 50fa3f7c on 2026-01-11
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import strawberry
|
||||
from fastapi import FastAPI
|
||||
from strawberry.fastapi import GraphQLRouter
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class User:
|
||||
name: str
|
||||
age: int
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class Query:
|
||||
@strawberry.field
|
||||
def user(self) -> User:
|
||||
return User(name="Patrick", age=100)
|
||||
|
||||
|
||||
schema = strawberry.Schema(query=Query)
|
||||
|
||||
|
||||
graphql_app = GraphQLRouter(schema)
|
||||
|
||||
app = FastAPI()
|
||||
app.include_router(graphql_app, prefix="/graphql")
|
||||
Reference in New Issue
Block a user