Coverage for docs_src / graphql_ / tutorial001_py310.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-12 18:15 +0000

1import strawberry 1abcd

2from fastapi import FastAPI 1abcd

3from strawberry.fastapi import GraphQLRouter 1abcd

4 

5 

6@strawberry.type 1abcd

7class User: 1abcd

8 name: str 1abcd

9 age: int 1abcd

10 

11 

12@strawberry.type 1abcd

13class Query: 1abcd

14 @strawberry.field 1abcd

15 def user(self) -> User: 1abcd

16 return User(name="Patrick", age=100) 1efg

17 

18 

19schema = strawberry.Schema(query=Query) 1abcd

20 

21 

22graphql_app = GraphQLRouter(schema) 1abcd

23 

24app = FastAPI() 1abcd

25app.include_router(graphql_app, prefix="/graphql") 1abcd