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
92 - name: must not allow input object as field type
93 input: |
94 input Input {
95 id: ID
96 }
97 type Query {
98 input: Input!
99 }
100 error:
101 message: 'OBJECT field must be one of SCALAR, OBJECT, INTERFACE, UNION, ENUM.'
102 locations: [{line: 5, column: 3}]
103
104interfaces:
105 - name: must exist
106 input: |
107 type Thing implements Object {
108 id: ID!
109 }
110
111 type Query {
112 Things: [Thing!]!
113 }
114 error:
115 message: 'Undefined type "Object".'
116 locations: [{line: 1, column: 6}]
117
118 - name: must be an interface
119 input: |
120 type Thing implements Object {
121 id: ID!
122 }
123
124 type Query {
125 Things: [Thing!]!
126 }
127
128 type Object {
129 name: String
130 }
131 error:
132 message: '"Object" is a non interface type OBJECT.'
133 locations: [{line: 1, column: 6}]
134
135 - name: must define one or more fields
136 input: |
137 directive @D on INTERFACE
138
139 # This pattern rejected by parser
140 # interface InvalidInterface1 {}
141
142 interface InvalidInterface2 @D
143
144 interface ValidInterface {
145 id: ID
146 }
147 extend interface ValidInterface @D
148 extend interface ValidInterface {
149 b: Int
150 }
151 error:
152 message: 'INTERFACE must define one or more fields.'
153 locations: [{line: 6, column: 11}]
154 - name: check reserved names on type name
155 input: |
156 interface __FooBar {
157 id: ID
158 }
159 error:
160 message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
161 locations: [{line: 1, column: 11}]
162
163 - name: must not allow input object as field type
164 input: |
165 input Input {
166 id: ID
167 }
168 type Query {
169 foo: Foo!
170 }
171 interface Foo {
172 input: Input!
173 }
174 error:
175 message: 'INTERFACE field must be one of SCALAR, OBJECT, INTERFACE, UNION, ENUM.'
176 locations: [{line: 8, column: 3}]
177
178 - name: must have all fields from interface
179 input: |
180 type Bar implements BarInterface {
181 someField: Int!
182 }
183
184 interface BarInterface {
185 id: ID!
186 }
187 error:
188 message: 'For Bar to implement BarInterface it must have a field called id.'
189 locations: [{line: 1, column: 6}]
190
191 - name: must have same type of fields
192 input: |
193 type Bar implements BarInterface {
194 id: Int!
195 }
196
197 interface BarInterface {
198 id: ID!
199 }
200 error:
201 message: 'For Bar to implement BarInterface the field id must have type ID!.'
202 locations: [{line: 2, column: 5}]
203
204 - name: must have all required arguments
205 input: |
206 type Bar implements BarInterface {
207 id: ID!
208 }
209
210 interface BarInterface {
211 id(ff: Int!): ID!
212 }
213 error:
214 message: 'For Bar to implement BarInterface the field id must have the same arguments but it is missing ff.'
215 locations: [{line: 2, column: 5}]
216
217 - name: must have same argument types
218 input: |
219 type Bar implements BarInterface {
220 id(ff: ID!): ID!
221 }
222
223 interface BarInterface {
224 id(ff: Int!): ID!
225 }
226 error:
227 message: 'For Bar to implement BarInterface the field id must have the same arguments but ff has the wrong type.'
228 locations: [{line: 2, column: 8}]
229
230 - name: may defined additional nullable arguments
231 input: |
232 type Bar implements BarInterface {
233 id(opt: Int): ID!
234 }
235
236 interface BarInterface {
237 id: ID!
238 }
239
240 - name: may defined additional required arguments with defaults
241 input: |
242 type Bar implements BarInterface {
243 id(opt: Int! = 1): ID!
244 }
245
246 interface BarInterface {
247 id: ID!
248 }
249
250 - name: must not define additional required arguments without defaults
251 input: |
252 type Bar implements BarInterface {
253 id(opt: Int!): ID!
254 }
255
256 interface BarInterface {
257 id: ID!
258 }
259 error:
260 message: 'For Bar to implement BarInterface any additional arguments on id must be optional or have a default value but opt is required.'
261 locations: [{line: 2, column: 8}]
262
263 - name: can have covariant argument types
264 input: |
265 union U = A|B
266
267 type A { name: String }
268 type B { name: String }
269
270 type Bar implements BarInterface {
271 f: A!
272 }
273
274 interface BarInterface {
275 f: U!
276 }
277
278inputs:
279 - name: must define one or more input fields
280 input: |
281 directive @D on INPUT_OBJECT
282
283 # This pattern rejected by parser
284 # input InvalidInput1 {}
285
286 input InvalidInput2 @D
287
288 input ValidInput {
289 id: ID
290 }
291 extend input ValidInput @D
292 extend input ValidInput {
293 b: Int
294 }
295 error:
296 message: 'INPUT_OBJECT must define one or more input fields.'
297 locations: [{line: 6, column: 7}]
298 - name: check reserved names on type name
299 input: |
300 input __FooBar {
301 id: ID
302 }
303 error:
304 message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
305 locations: [{line: 1, column: 7}]
306
307 - name: fields cannot be Objects
308 input: |
309 type Object { id: ID }
310 input Foo { a: Object! }
311 error:
312 message: INPUT_OBJECT field must be one of SCALAR, ENUM, INPUT_OBJECT.
313 locations: [{line: 2, column: 13}]
314
315 - name: fields cannot be Interfaces
316 input: |
317 interface Interface { id: ID! }
318 input Foo { a: Interface! }
319 error:
320 message: INPUT_OBJECT field must be one of SCALAR, ENUM, INPUT_OBJECT.
321 locations: [{line: 2, column: 13}]
322
323 - name: fields cannot be Unions
324 input: |
325 type Object { id: ID }
326 union Union = Object
327 input Foo { a: Union! }
328 error:
329 message: INPUT_OBJECT field must be one of SCALAR, ENUM, INPUT_OBJECT.
330 locations: [{line: 3, column: 13}]
331
332args:
333 - name: Valid arg types
334 input: |
335 input Input { id: ID }
336 enum Enum { A }
337 scalar Scalar
338
339 type Query {
340 f(a: Input, b: Scalar, c: Enum): Boolean!
341 }
342
343 - name: Objects not allowed
344 input: |
345 type Object { id: ID }
346 type Query { f(a: Object): Boolean! }
347
348 error:
349 message: 'cannot use Object as argument a because OBJECT is not a valid input type'
350 locations: [{line: 2, column: 16}]
351
352 - name: Union not allowed
353 input: |
354 type Object { id: ID }
355 union Union = Object
356 type Query { f(a: Union): Boolean! }
357
358 error:
359 message: 'cannot use Union as argument a because UNION is not a valid input type'
360 locations: [{line: 3, column: 16}]
361
362 - name: Interface not allowed
363 input: |
364 interface Interface { id: ID }
365 type Query { f(a: Interface): Boolean! }
366
367 error:
368 message: 'cannot use Interface as argument a because INTERFACE is not a valid input type'
369 locations: [{line: 2, column: 16}]
370
371enums:
372 - name: must define one or more unique enum values
373 input: |
374 directive @D on ENUM
375
376 # This pattern rejected by parser
377 # enum InvalidEmum1 {}
378
379 enum InvalidEnum2 @D
380
381 enum ValidEnum {
382 FOO
383 }
384 extend enum ValidEnum @D
385 extend enum ValidEnum {
386 BAR
387 }
388 error:
389 message: 'ENUM must define one or more unique enum values.'
390 locations: [{line: 6, column: 6}]
391 - name: check reserved names on type name
392 input: |
393 enum __FooBar {
394 A
395 B
396 }
397 error:
398 message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
399 locations: [{line: 1, column: 6}]
400
401unions:
402 - name: union types must be defined
403 input: |
404 union Foo = Bar | Baz
405 type Bar {
406 id: ID
407 }
408 error:
409 message: "Undefined type \"Baz\"."
410 locations: [{line: 1, column: 7}]
411 - name: union types must be objects
412 input: |
413 union Foo = Baz
414 interface Baz {
415 id: ID
416 }
417 error:
418 message: "UNION type \"Baz\" must be OBJECT."
419 locations: [{line: 1, column: 7}]
420
421 - name: unions of pure type extensions are valid
422 input: |
423
424 type Review {
425 body: String!
426 author: User! @provides(fields: "username")
427 product: Product!
428 }
429
430 extend type User @key(fields: "id") {
431 id: ID! @external
432 reviews: [Review]
433 }
434
435 extend type Product @key(fields: "upc") {
436 upc: String! @external
437 reviews: [Review]
438 }
439
440 union Foo = User | Product
441 scalar _Any
442 scalar _FieldSet
443 directive @external on FIELD_DEFINITION
444 directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
445 directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
446 directive @key(fields: _FieldSet!) on OBJECT | INTERFACE
447 directive @extends on OBJECT
448
449
450
451type extensions:
452 - name: can extend non existant types
453 input: |
454 extend type A {
455 name: String
456 }
457
458
459 - name: cannot extend incorret type existant types
460 input: |
461 scalar A
462 extend type A {
463 name: String
464 }
465 error:
466 message: "Cannot extend type A because the base type is a SCALAR, not OBJECT."
467 locations: [{line: 2, column: 13}]
468
469directives:
470 - name: cannot redeclare directives
471 input: |
472 directive @A on FIELD_DEFINITION
473 directive @A on FIELD_DEFINITION
474 error:
475 message: "Cannot redeclare directive A."
476 locations: [{line: 2, column: 12}]
477
478 - name: must be declared
479 input: |
480 type User {
481 name: String @foo
482 }
483 error:
484 message: "Undefined directive foo."
485 locations: [{line: 2, column: 17}]
486
487 - name: cannot be self-referential
488 input: |
489 directive @A(foo: Int! @A) on FIELD_DEFINITION
490 error:
491 message: "Directive A cannot refer to itself."
492 locations: [{line: 1, column: 25}]
493 - name: check reserved names on type name
494 input: |
495 directive @__A on FIELD_DEFINITION
496 error:
497 message: 'Name "__A" must not begin with "__", which is reserved by GraphQL introspection.'
498 locations: [{line: 1, column: 12}]
499
500 - name: Valid arg types
501 input: |
502 input Input { id: ID }
503 enum Enum { A }
504 scalar Scalar
505
506 directive @A(a: Input, b: Scalar, c: Enum) on FIELD_DEFINITION
507
508 - name: Objects not allowed
509 input: |
510 type Object { id: ID }
511 directive @A(a: Object) on FIELD_DEFINITION
512
513 error:
514 message: 'cannot use Object as argument a because OBJECT is not a valid input type'
515 locations: [{line: 2, column: 14}]
516
517 - name: Union not allowed
518 input: |
519 type Object { id: ID }
520 union Union = Object
521 directive @A(a: Union) on FIELD_DEFINITION
522
523 error:
524 message: 'cannot use Union as argument a because UNION is not a valid input type'
525 locations: [{line: 3, column: 14}]
526
527 - name: Interface not allowed
528 input: |
529 interface Interface { id: ID }
530 directive @A(a: Interface) on FIELD_DEFINITION
531
532 error:
533 message: 'cannot use Interface as argument a because INTERFACE is not a valid input type'
534 locations: [{line: 2, column: 14}]
535
536entry points:
537 - name: multiple schema entry points
538 input: |
539 schema {
540 query: Query
541 }
542 schema {
543 query: Query
544 }
545 scalar Query
546 error:
547 message: "Cannot have multiple schema entry points, consider schema extensions instead."
548 locations: [{line: 4, column: 8}]
549
550 - name: Undefined schema entrypoint
551 input: |
552 schema {
553 query: Query
554 }
555 error:
556 message: "Schema root query refers to a type Query that does not exist."
557 locations: [{line: 2, column: 3}]
558
559entry point extensions:
560 - name: Undefined schema entrypoint
561 input: |
562 schema {
563 query: Query
564 }
565 scalar Query
566 extend schema {
567 mutation: Mutation
568 }
569 error:
570 message: "Schema root mutation refers to a type Mutation that does not exist."
571 locations: [{line: 6, column: 3}]
572
573type references:
574 - name: Field types
575 input: |
576 type User {
577 posts: Post
578 }
579 error:
580 message: "Undefined type Post."
581 locations: [{line: 2, column: 10}]
582
583 - name: Arg types
584 input: |
585 type User {
586 posts(foo: FooBar): String
587 }
588 error:
589 message: "Undefined type FooBar."
590 locations: [{line: 2, column: 14}]
591
592 - name: Directive arg types
593 input: |
594 directive @Foo(foo: FooBar) on FIELD_DEFINITION
595
596 error:
597 message: "Undefined type FooBar."
598 locations: [{line: 1, column: 21}]
View as plain text