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 InvalidObject2: 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 Query: 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 InvalidInterface2: must define one or more fields.'
153 locations: [{line: 6, column: 11}]
154
155 - name: check reserved names on type name
156 input: |
157 interface __FooBar {
158 id: ID
159 }
160 error:
161 message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
162 locations: [{line: 1, column: 11}]
163
164 - name: must not allow input object as field type
165 input: |
166 input Input {
167 id: ID
168 }
169 type Query {
170 foo: Foo!
171 }
172 interface Foo {
173 input: Input!
174 }
175 error:
176 message: 'INTERFACE Foo: field must be one of SCALAR, OBJECT, INTERFACE, UNION, ENUM.'
177 locations: [{line: 8, column: 3}]
178
179 - name: must have all fields from interface
180 input: |
181 type Bar implements BarInterface {
182 someField: Int!
183 }
184
185 interface BarInterface {
186 id: ID!
187 }
188 error:
189 message: 'For Bar to implement BarInterface it must have a field called id.'
190 locations: [{line: 1, column: 6}]
191
192 - name: must have same type of fields
193 input: |
194 type Bar implements BarInterface {
195 id: Int!
196 }
197
198 interface BarInterface {
199 id: ID!
200 }
201 error:
202 message: 'For Bar to implement BarInterface the field id must have type ID!.'
203 locations: [{line: 2, column: 5}]
204
205 - name: must have all required arguments
206 input: |
207 type Bar implements BarInterface {
208 id: ID!
209 }
210
211 interface BarInterface {
212 id(ff: Int!): ID!
213 }
214 error:
215 message: 'For Bar to implement BarInterface the field id must have the same arguments but it is missing ff.'
216 locations: [{line: 2, column: 5}]
217
218 - name: must have same argument types
219 input: |
220 type Bar implements BarInterface {
221 id(ff: ID!): ID!
222 }
223
224 interface BarInterface {
225 id(ff: Int!): ID!
226 }
227 error:
228 message: 'For Bar to implement BarInterface the field id must have the same arguments but ff has the wrong type.'
229 locations: [{line: 2, column: 8}]
230
231 - name: may defined additional nullable arguments
232 input: |
233 type Bar implements BarInterface {
234 id(opt: Int): ID!
235 }
236
237 interface BarInterface {
238 id: ID!
239 }
240
241 - name: may defined additional required arguments with defaults
242 input: |
243 type Bar implements BarInterface {
244 id(opt: Int! = 1): ID!
245 }
246
247 interface BarInterface {
248 id: ID!
249 }
250
251 - name: must not define additional required arguments without defaults
252 input: |
253 type Bar implements BarInterface {
254 id(opt: Int!): ID!
255 }
256
257 interface BarInterface {
258 id: ID!
259 }
260 error:
261 message: 'For Bar to implement BarInterface any additional arguments on id must be optional or have a default value but opt is required.'
262 locations: [{line: 2, column: 8}]
263
264 - name: can have covariant argument types
265 input: |
266 union U = A|B
267
268 type A { name: String }
269 type B { name: String }
270
271 type Bar implements BarInterface {
272 f: A!
273 }
274
275 interface BarInterface {
276 f: U!
277 }
278
279 - name: may define intermediate interfaces
280 input: |
281 interface IA {
282 id: ID!
283 }
284
285 interface IIA implements IA {
286 id: ID!
287 }
288
289 type A implements IIA & IA {
290 id: ID!
291 }
292
293 - name: Type Foo must implement Baz because it is implemented by Bar
294 input: |
295 interface Baz {
296 baz: String
297 }
298
299 interface Bar implements Baz {
300 bar: String
301 baz: String
302 }
303
304 type Foo implements Bar {
305 foo: String
306 bar: String
307 baz: String
308 }
309 error:
310 message: 'Type Foo must implement Baz because it is implemented by Bar.'
311 locations: [{line: 10, column: 6}]
312
313 - name: circular reference error
314 input: |
315 interface Circular1 implements Circular2 {
316 id: ID!
317 }
318
319 interface Circular2 implements Circular1 {
320 id: ID!
321 }
322 error:
323 message: 'Type Circular1 cannot implement Circular2 because it would create a circular reference.'
324 locations: [{line: 1, column: 11}]
325
326inputs:
327 - name: must define one or more input fields
328 input: |
329 directive @D on INPUT_OBJECT
330
331 # This pattern rejected by parser
332 # input InvalidInput1 {}
333
334 input InvalidInput2 @D
335
336 input ValidInput {
337 id: ID
338 }
339 extend input ValidInput @D
340 extend input ValidInput {
341 b: Int
342 }
343 error:
344 message: 'INPUT_OBJECT InvalidInput2: must define one or more input fields.'
345 locations: [{line: 6, column: 7}]
346 - name: check reserved names on type name
347 input: |
348 input __FooBar {
349 id: ID
350 }
351 error:
352 message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
353 locations: [{line: 1, column: 7}]
354
355 - name: fields cannot be Objects
356 input: |
357 type Object { id: ID }
358 input Foo { a: Object! }
359 error:
360 message: 'OBJECT a: field must be one of SCALAR, ENUM, INPUT_OBJECT.'
361 locations: [{line: 2, column: 13}]
362
363 - name: fields cannot be Interfaces
364 input: |
365 interface Interface { id: ID! }
366 input Foo { a: Interface! }
367 error:
368 message: 'INTERFACE a: field must be one of SCALAR, ENUM, INPUT_OBJECT.'
369 locations: [{line: 2, column: 13}]
370
371 - name: fields cannot be Unions
372 input: |
373 type Object { id: ID }
374 union Union = Object
375 input Foo { a: Union! }
376 error:
377 message: 'UNION a: field must be one of SCALAR, ENUM, INPUT_OBJECT.'
378 locations: [{line: 3, column: 13}]
379
380args:
381 - name: Valid arg types
382 input: |
383 input Input { id: ID }
384 enum Enum { A }
385 scalar Scalar
386
387 type Query {
388 f(a: Input, b: Scalar, c: Enum): Boolean!
389 }
390
391 - name: Objects not allowed
392 input: |
393 type Object { id: ID }
394 type Query { f(a: Object): Boolean! }
395
396 error:
397 message: 'cannot use Object as argument a because OBJECT is not a valid input type'
398 locations: [{line: 2, column: 16}]
399
400 - name: Union not allowed
401 input: |
402 type Object { id: ID }
403 union Union = Object
404 type Query { f(a: Union): Boolean! }
405
406 error:
407 message: 'cannot use Union as argument a because UNION is not a valid input type'
408 locations: [{line: 3, column: 16}]
409
410 - name: Interface not allowed
411 input: |
412 interface Interface { id: ID }
413 type Query { f(a: Interface): Boolean! }
414
415 error:
416 message: 'cannot use Interface as argument a because INTERFACE is not a valid input type'
417 locations: [{line: 2, column: 16}]
418
419enums:
420 - name: must define one or more unique enum values
421 input: |
422 directive @D on ENUM
423
424 # This pattern rejected by parser
425 # enum InvalidEmum1 {}
426
427 enum InvalidEnum2 @D
428
429 enum ValidEnum {
430 FOO
431 }
432 extend enum ValidEnum @D
433 extend enum ValidEnum {
434 BAR
435 }
436 error:
437 message: 'ENUM InvalidEnum2: must define one or more unique enum values.'
438 locations: [{line: 6, column: 6}]
439 - name: check reserved names on type name
440 input: |
441 enum __FooBar {
442 A
443 B
444 }
445 error:
446 message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
447 locations: [{line: 1, column: 6}]
448
449unions:
450 - name: union types must be defined
451 input: |
452 union Foo = Bar | Baz
453 type Bar {
454 id: ID
455 }
456 error:
457 message: "Undefined type \"Baz\"."
458 locations: [{line: 1, column: 7}]
459 - name: union types must be objects
460 input: |
461 union Foo = Baz
462 interface Baz {
463 id: ID
464 }
465 error:
466 message: "UNION type \"Baz\" must be OBJECT."
467 locations: [{line: 1, column: 7}]
468
469 - name: unions of pure type extensions are valid
470 input: |
471
472 type Review {
473 body: String!
474 author: User! @provides(fields: "username")
475 product: Product!
476 }
477
478 extend type User @key(fields: "id") {
479 id: ID! @external
480 reviews: [Review]
481 }
482
483 extend type Product @key(fields: "upc") {
484 upc: String! @external
485 reviews: [Review]
486 }
487
488 union Foo = User | Product
489 scalar _Any
490 scalar _FieldSet
491 directive @external on FIELD_DEFINITION
492 directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
493 directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
494 directive @key(fields: _FieldSet!) on OBJECT | INTERFACE
495 directive @extends on OBJECT
496
497
498
499type extensions:
500 - name: can extend non existant types
501 input: |
502 extend type A {
503 name: String
504 }
505
506
507 - name: cannot extend incorret type existant types
508 input: |
509 scalar A
510 extend type A {
511 name: String
512 }
513 error:
514 message: "Cannot extend type A because the base type is a SCALAR, not OBJECT."
515 locations: [{line: 2, column: 13}]
516
517directives:
518 - name: cannot redeclare directives
519 input: |
520 directive @A on FIELD_DEFINITION
521 directive @A on FIELD_DEFINITION
522 error:
523 message: "Cannot redeclare directive A."
524 locations: [{line: 2, column: 12}]
525
526 - name: can redeclare builtin directives
527 input: |
528 directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
529 directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
530
531 - name: must be declared (type)
532 input: |
533 type User @foo {
534 name: String
535 }
536 error:
537 message: "Undefined directive foo."
538 locations: [{line: 1, column: 12}]
539
540 - name: must be declared (field)
541 input: |
542 type User {
543 name: String @foo
544 }
545 error:
546 message: "Undefined directive foo."
547 locations: [{line: 2, column: 17}]
548
549 - name: must be declared (enum)
550 input: |
551 enum Unit {
552 METER @foo
553 }
554 error:
555 message: "Undefined directive foo."
556 locations: [{line: 2, column: 10}]
557
558 - name: cannot be self-referential
559 input: |
560 directive @A(foo: Int! @A) on FIELD_DEFINITION
561 error:
562 message: "Directive A cannot refer to itself."
563 locations: [{line: 1, column: 25}]
564 - name: check reserved names on type name
565 input: |
566 directive @__A on FIELD_DEFINITION
567 error:
568 message: 'Name "__A" must not begin with "__", which is reserved by GraphQL introspection.'
569 locations: [{line: 1, column: 12}]
570
571 - name: Valid arg types
572 input: |
573 input Input { id: ID }
574 enum Enum { A }
575 scalar Scalar
576
577 directive @A(a: Input, b: Scalar, c: Enum) on FIELD_DEFINITION
578
579 - name: Objects not allowed
580 input: |
581 type Object { id: ID }
582 directive @A(a: Object) on FIELD_DEFINITION
583
584 error:
585 message: 'cannot use Object as argument a because OBJECT is not a valid input type'
586 locations: [{line: 2, column: 14}]
587
588 - name: Union not allowed
589 input: |
590 type Object { id: ID }
591 union Union = Object
592 directive @A(a: Union) on FIELD_DEFINITION
593
594 error:
595 message: 'cannot use Union as argument a because UNION is not a valid input type'
596 locations: [{line: 3, column: 14}]
597
598 - name: Interface not allowed
599 input: |
600 interface Interface { id: ID }
601 directive @A(a: Interface) on FIELD_DEFINITION
602
603 error:
604 message: 'cannot use Interface as argument a because INTERFACE is not a valid input type'
605 locations: [{line: 2, column: 14}]
606
607 - name: Invalid location usage not allowed
608 input: |
609 directive @test on FIELD_DEFINITION
610 input I1 @test { f: String }
611
612 error:
613 message: 'Directive test is not applicable on INPUT_OBJECT.'
614 locations: [{line: 2, column: 11}]
615
616 - name: Valid location usage
617 input: |
618 directive @testInputField on INPUT_FIELD_DEFINITION
619 directive @testField on FIELD_DEFINITION
620 directive @inp on INPUT_OBJECT
621 input I1 @inp { f: String @testInputField }
622 type P { name: String @testField }
623 interface I { id: ID @testField }
624
625 - name: Invalid directive argument not allowed
626 input: |
627 directive @foo(bla: Int!) on FIELD_DEFINITION
628 type P {f: Int @foo(foobla: 11)}
629
630 error:
631 message: 'Undefined argument foobla for directive foo.'
632 locations: [{line: 2, column: 21}]
633
634 - name: non-null argument must be provided
635 input: |
636 directive @foo(bla: Int!) on FIELD_DEFINITION
637 type P {f: Int @foo }
638
639 error:
640 message: 'Argument bla for directive foo cannot be null.'
641 locations: [{line: 2, column: 17}]
642
643 - name: non-null argument must not be null
644 input: |
645 directive @foo(bla: Int!) on FIELD_DEFINITION
646 type P {f: Int @foo(bla: null) }
647
648 error:
649 message: 'Argument bla for directive foo cannot be null.'
650 locations: [{line: 2, column: 17}]
651
652entry points:
653 - name: multiple schema entry points
654 input: |
655 schema {
656 query: Query
657 }
658 schema {
659 query: Query
660 }
661 scalar Query
662 error:
663 message: "Cannot have multiple schema entry points, consider schema extensions instead."
664 locations: [{line: 4, column: 8}]
665
666 - name: Undefined schema entrypoint
667 input: |
668 schema {
669 query: Query
670 }
671 error:
672 message: "Schema root query refers to a type Query that does not exist."
673 locations: [{line: 2, column: 3}]
674
675entry point extensions:
676 - name: Undefined schema entrypoint
677 input: |
678 schema {
679 query: Query
680 }
681 scalar Query
682 extend schema {
683 mutation: Mutation
684 }
685 error:
686 message: "Schema root mutation refers to a type Mutation that does not exist."
687 locations: [{line: 6, column: 3}]
688
689type references:
690 - name: Field types
691 input: |
692 type User {
693 posts: Post
694 }
695 error:
696 message: "Undefined type Post."
697 locations: [{line: 2, column: 10}]
698
699 - name: Arg types
700 input: |
701 type User {
702 posts(foo: FooBar): String
703 }
704 error:
705 message: "Undefined type FooBar."
706 locations: [{line: 2, column: 14}]
707
708 - name: Directive arg types
709 input: |
710 directive @Foo(foo: FooBar) on FIELD_DEFINITION
711
712 error:
713 message: "Undefined type FooBar."
714 locations: [{line: 1, column: 21}]
715
716 - name: Invalid enum value
717 input: |
718 enum Enum { true }
719
720 error:
721 message: "ENUM Enum: non-enum value true."
722 locations: [{line: 1, column: 6}]
View as plain text