-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.py
153 lines (135 loc) · 3.96 KB
/
schema.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
from typing import Annotated
from swapi.context import Context
from swapi.film import Film, FilmsConnection, FilmsEdge
from swapi.node import Node
from swapi.people import PeopleConnection, PeopleEdge, Person
from swapi.planets import Planet, PlanetsConnection, PlanetsEdge
from swapi.species import Species, SpeciesConnection, SpeciesEdge
from swapi.starships import Starship, StarshipsConnection, StarshipsEdge
from swapi.utils.connections import get_connection_resolver
from swapi.vehicles import Vehicle, VehiclesConnection, VehiclesEdge
import strawberry
from strawberry.types.info import Info
@strawberry.type
class Root:
all_films: FilmsConnection | None = strawberry.field(
resolver=get_connection_resolver(
"film",
FilmsConnection,
FilmsEdge,
Film,
attribute_name="films",
)
)
all_people: PeopleConnection | None = strawberry.field(
resolver=get_connection_resolver(
"person",
PeopleConnection,
PeopleEdge,
Person,
attribute_name="people",
)
)
all_planets: PlanetsConnection | None = strawberry.field(
resolver=get_connection_resolver(
"planet",
PlanetsConnection,
PlanetsEdge,
Planet,
attribute_name="planets",
)
)
all_species: SpeciesConnection | None = strawberry.field(
resolver=get_connection_resolver(
"species",
SpeciesConnection,
SpeciesEdge,
Species,
attribute_name="species",
)
)
all_vehicles: VehiclesConnection | None = strawberry.field(
resolver=get_connection_resolver(
"vehicle",
VehiclesConnection,
VehiclesEdge,
Vehicle,
attribute_name="vehicles",
)
)
all_starships: StarshipsConnection | None = strawberry.field(
resolver=get_connection_resolver(
"starship",
StarshipsConnection,
StarshipsEdge,
Starship,
attribute_name="starships",
)
)
@strawberry.field
def film(
self,
info: Info[Context, None],
id: strawberry.ID | None,
film_id: Annotated[strawberry.ID | None, strawberry.argument(name="filmID")],
) -> Film | None:
return None
@strawberry.field
def person(
self,
info: Info[Context, None],
id: strawberry.ID | None,
person_id: Annotated[
strawberry.ID | None, strawberry.argument(name="personID")
],
) -> Person | None:
return None
@strawberry.field
def planet(
self,
info: Info[Context, None],
id: strawberry.ID | None,
planet_id: Annotated[
strawberry.ID | None, strawberry.argument(name="planetID")
],
) -> Planet | None:
return None
@strawberry.field
def species(
self,
info: Info[Context, None],
id: strawberry.ID | None,
species_id: Annotated[
strawberry.ID | None, strawberry.argument(name="speciesID")
],
) -> Species | None:
return None
@strawberry.field
def vehicle(
self,
info: Info[Context, None],
id: strawberry.ID | None,
vehicle_id: Annotated[
strawberry.ID | None, strawberry.argument(name="vehicleID")
],
) -> Vehicle | None:
return None
@strawberry.field
def starship(
self,
info: Info[Context, None],
id: strawberry.ID | None,
starship_id: Annotated[
strawberry.ID | None, strawberry.argument(name="starshipID")
],
) -> Starship | None:
return None
@strawberry.field
def node(
self,
info: Info[Context, None],
id: strawberry.ID,
) -> Node | None:
# TODO: implement this
return None
schema = strawberry.Schema(query=Root)