1types:
2 - name: cannot be redeclared
3 input: |
4 type A {
5 name: String
6 }
7 type A {
8 name: String
9 }
10 error:
11 message: "Cannot redeclare type A."
12 locations: [{line: 4, column: 6}]
13 - name: cannot be duplicated field at same definition 1
14 input: |
15 type A {
16 name: String
17 name: String
18 }
19 error:
20 message: "Field A.name can only be defined once."
21 locations: [{line: 3, column: 3}]
22 - name: cannot be duplicated field at same definition 2
23 input: |
24 type A {
25 name: String
26 }
27 extend type A {
28 name: String
29 }
30 error:
31 message: "Field A.name can only be defined once."
32 locations: [{line: 5, column: 3}]
33 - name: cannot be duplicated field at same definition 3
34 input: |
35 type A {
36 name: String
37 }
38 extend type A {
39 age: Int
40 age: Int
41 }
42 error:
43 message: "Field A.age can only be defined once."
44 locations: [{line: 6, column: 3}]
45
46object types:
47 - name: must define one or more fields
48 input: |
49 directive @D on OBJECT
50
51 # This pattern rejected by parser
52 # type InvalidObject1 {}
53
54 type InvalidObject2 @D
55
56 type ValidObject {
57 id: ID
58 }
59 extend type ValidObject @D
60 extend type ValidObject {
61 b: Int
62 }
63 error:
64 message: 'OBJECT must define one or more fields.'
65 locations: [{line: 6, column: 6}]
66 - name: check reserved names on type name
67 input: |
68 type __FooBar {
69 id: ID
70 }
71 error:
72 message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
73 locations: [{line: 1, column: 6}]
74 - name: check reserved names on type field
75 input: |
76 type FooBar {
77 __id: ID
78 }
79 error:
80 message: 'Name "__id" must not begin with "__", which is reserved by GraphQL introspection.'
81 locations: [{line: 2, column: 3}]
82
83 - name: check reserved names on type field argument
84 input: |
85 type FooBar {
86 foo(__bar: ID): ID
87 }
88 error:
89 message: 'Name "__bar" must not begin with "__", which is reserved by GraphQL introspection.'
90 locations: [{line: 2, column: 7}]
91
92interfaces:
93 - name: must exist
94 input: |
95 type Thing implements Object {
96 id: ID!
97 }
98
99 type Query {
100 Things: [Thing!]!
101 }
102 error:
103 message: 'Undefined type "Object".'
104 locations: [{line: 1, column: 6}]
105
106 - name: must be an interface
107 input: |
108 type Thing implements Object {
109 id: ID!
110 }
111
112 type Query {
113 Things: [Thing!]!
114 }
115
116 type Object {
117 name: String
118 }
119 error:
120 message: '"Object" is a non interface type OBJECT.'
121 locations: [{line: 1, column: 6}]
122
123 - name: must define one or more fields
124 input: |
125 directive @D on INTERFACE
126
127 # This pattern rejected by parser
128 # interface InvalidInterface1 {}
129
130 interface InvalidInterface2 @D
131
132 interface ValidInterface {
133 id: ID
134 }
135 extend interface ValidInterface @D
136 extend interface ValidInterface {
137 b: Int
138 }
139 error:
140 message: 'INTERFACE must define one or more fields.'
141 locations: [{line: 6, column: 11}]
142 - name: check reserved names on type name
143 input: |
144 interface __FooBar {
145 id: ID
146 }
147 error:
148 message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
149 locations: [{line: 1, column: 11}]
150
151inputs:
152 - name: must define one or more input fields
153 input: |
154 directive @D on INPUT_OBJECT
155
156 # This pattern rejected by parser
157 # input InvalidInput1 {}
158
159 input InvalidInput2 @D
160
161 input ValidInput {
162 id: ID
163 }
164 extend input ValidInput @D
165 extend input ValidInput {
166 b: Int
167 }
168 error:
169 message: 'INPUT_OBJECT must define one or more input fields.'
170 locations: [{line: 6, column: 7}]
171 - name: check reserved names on type name
172 input: |
173 input __FooBar {
174 id: ID
175 }
176 error:
177 message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
178 locations: [{line: 1, column: 7}]
179
180enums:
181 - name: must define one or more unique enum values
182 input: |
183 directive @D on ENUM
184
185 # This pattern rejected by parser
186 # enum InvalidEmum1 {}
187
188 enum InvalidEnum2 @D
189
190 enum ValidEnum {
191 FOO
192 }
193 extend enum ValidEnum @D
194 extend enum ValidEnum {
195 BAR
196 }
197 error:
198 message: 'ENUM must define one or more unique enum values.'
199 locations: [{line: 6, column: 6}]
200 - name: check reserved names on type name
201 input: |
202 enum __FooBar {
203 A
204 B
205 }
206 error:
207 message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
208 locations: [{line: 1, column: 6}]
209
210type extensions:
211 - name: cannot extend non existant types
212 input: |
213 extend type A {
214 name: String
215 }
216 error:
217 message: "Cannot extend type A because it does not exist."
218 locations: [{line: 1, column: 13}]
219
220 - name: cannot extend incorret type existant types
221 input: |
222 scalar A
223 extend type A {
224 name: String
225 }
226 error:
227 message: "Cannot extend type A because the base type is a SCALAR, not OBJECT."
228 locations: [{line: 2, column: 13}]
229
230directives:
231 - name: cannot redeclare directives
232 input: |
233 directive @A on FIELD_DEFINITION
234 directive @A on FIELD_DEFINITION
235 error:
236 message: "Cannot redeclare directive A."
237 locations: [{line: 2, column: 12}]
238
239 - name: must be declared
240 input: |
241 type User {
242 name: String @foo
243 }
244 error:
245 message: "Undefined directive foo."
246 locations: [{line: 2, column: 17}]
247
248 - name: cannot be self-referential
249 input: |
250 directive @A(foo: Int! @A) on FIELD_DEFINITION
251 error:
252 message: "Directive A cannot refer to itself."
253 locations: [{line: 1, column: 25}]
254 - name: check reserved names on type name
255 input: |
256 directive @__A on FIELD_DEFINITION
257 error:
258 message: 'Name "__A" must not begin with "__", which is reserved by GraphQL introspection.'
259 locations: [{line: 1, column: 12}]
260
261entry points:
262 - name: multiple schema entry points
263 input: |
264 schema {
265 query: Query
266 }
267 schema {
268 query: Query
269 }
270 scalar Query
271 error:
272 message: "Cannot have multiple schema entry points, consider schema extensions instead."
273 locations: [{line: 4, column: 8}]
274
275 - name: Undefined schema entrypoint
276 input: |
277 schema {
278 query: Query
279 }
280 error:
281 message: "Schema root query refers to a type Query that does not exist."
282 locations: [{line: 2, column: 3}]
283
284entry point extensions:
285 - name: Undefined schema entrypoint
286 input: |
287 schema {
288 query: Query
289 }
290 scalar Query
291 extend schema {
292 mutation: Mutation
293 }
294 error:
295 message: "Schema root mutation refers to a type Mutation that does not exist."
296 locations: [{line: 6, column: 3}]
297
298type references:
299 - name: Field types
300 input: |
301 type User {
302 posts: Post
303 }
304 error:
305 message: "Undefined type Post."
306 locations: [{line: 2, column: 10}]
307
308 - name: Arg types
309 input: |
310 type User {
311 posts(foo: FooBar): String
312 }
313 error:
314 message: "Undefined type FooBar."
315 locations: [{line: 2, column: 14}]
316
317 - name: Directive arg types
318 input: |
319 directive @Foo(foo: FooBar) on FIELD_DEFINITION
320
321 error:
322 message: "Undefined type FooBar."
323 locations: [{line: 1, column: 21}]