-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.js
147 lines (132 loc) · 3.18 KB
/
schema.js
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
const { gql } = require('apollo-server-express');
// Type definitions define the "shape" of your data and specify
// which ways the data can be fetched from the GraphQL server.
module.exports = gql`
# Comments in GraphQL are defined with the hash (#) symbol.
type _QueryMeta@cacheControl(maxAge: 3600) {
count: Int!
itemsPerPage: Int
}
type _PaginatedPropertyMeta@cacheControl(maxAge: 3600) {
count: Int!
}
interface Node {
id: ID
}
type Person implements Node@cacheControl(maxAge: 240) {
id: ID
name: String
picture: String
gender: String
eye_color: String
hair_color: String
mass: String
skin_color: String
birth_year: String
homeworld: Planet
starships(first: Int = 6 offset: Int = 0): [Starship]
starshipsCount: Int
species(first: Int = 6 offset: Int = 0): [Species]
speciesCount: Int
vehicles(first: Int = 6 offset: Int = 0): [Vehicle]
vehiclesCount: Int
}
type personPages@cacheControl(maxAge: 3600) {
page: Int!,
count: Int!
items: [Person]
}
type Starship implements Node@cacheControl(maxAge: 3600) {
id: ID
name: String
model: String
starship_class: String
manufacturer: String
hyperdrive_rating: String
cargo_capacity: String
length: String
passengers: String
crew: String
consumables: String
MGLT: String
picture: String
pilots(first: Int = 6 offset: Int = 0): [Person]
pilotsCount: Int
}
type starshipPages@cacheControl(maxAge: 3600) {
page: Int!,
count: Int!
items: [Starship]
}
type Vehicle@cacheControl(maxAge: 3600) {
id: ID
name: String
model: String
manufacturer: String
vehicle_class: String
cargo_capacity: String
passengers: String
crew: String
consumables: String
picture: String
pilots(first: Int = 6 offset: Int = 0): [Person]
pilotsCount: Int
}
type vehiclePages@cacheControl(maxAge: 3600) {
page: Int!,
count: Int!
items: [Vehicle]
}
type Planet implements Node@cacheControl(maxAge: 3600) {
id: ID
name: String
terrain: String
climate: String
diameter: String
gravity: String
orbital_period: String
population: String
rotation_period: String
surface_water: String
picture: String
residents(first: Int = 6 offset: Int = 0): [Person]
residentsCount: Int
}
type planetPages@cacheControl(maxAge: 3600) {
page: Int!,
count: Int!
items: [Planet]
}
type Species implements Node@cacheControl(maxAge: 3600) {
id: ID
name: String
classification: String
homeworld: Planet
designation: String
language: String
average_height: String
average_lifespan: String
picture: String
people(first: Int = 6 offset: Int = 0): [Person]
peopleCount: Int
}
type speciesPages@cacheControl(maxAge: 3600) {
page: Int!,
count: Int!
items: [Species]
}
# The "Query" type is the root of all GraphQL queries.
# (A "Mutation" type will be covered later on.)
type Query {
Person(id: ID): Person
personPages(page: Int): personPages
Starship(id: ID): Starship
starshipPages(page: Int): starshipPages
Vehicle(id: ID): Vehicle
vehiclePages(page: Int): vehiclePages
Planet(id: ID): Planet
planetPages(page: Int): planetPages
Species(id: ID): Species
speciesPages(page: Int): speciesPages
}
`;