mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-24 16:29:41 -04:00
✅ Add missing tests for code examples (#14569)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Nils-Hero Lindemann <nilsherolindemann@proton.me>
This commit is contained in:
0
docs_src/graphql_/__init__.py
Normal file
0
docs_src/graphql_/__init__.py
Normal file
25
docs_src/graphql_/tutorial001_py39.py
Normal file
25
docs_src/graphql_/tutorial001_py39.py
Normal file
@@ -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