File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 11"""Schema definitions for geographies."""
22
3+ from typing import List
4+
35import strawberry
46import strawberry_django
7+ from strawberry .types import Info
58
69from api .models import Geography
710from api .types .type_geo import TypeGeo
1114class Query :
1215 """Queries for geographies."""
1316
14- geographies : list [TypeGeo ] = strawberry_django .field ()
15- geography : TypeGeo = strawberry_django .field ()
17+ @strawberry_django .field
18+ def geographies (self , info : Info ) -> List [TypeGeo ]:
19+ """Get all geographies."""
20+ geographies = Geography .objects .all ()
21+ return TypeGeo .from_django_list (geographies )
22+
23+ @strawberry_django .field
24+ def geography (self , info : Info , id : int ) -> TypeGeo :
25+ """Get a single geography by ID."""
26+ geography = Geography .objects .get (id = id )
27+ return TypeGeo .from_django (geography )
You can’t perform that action at this time.
0 commit comments