...
1object types:
2 - name: simple
3 input: |
4 type Hello {
5 world: String
6 }
7 ast: |
8 <SchemaDocument>
9 Definitions: [Definition]
10 - <Definition>
11 Kind: DefinitionKind("OBJECT")
12 Name: "Hello"
13 Fields: [FieldDefinition]
14 - <FieldDefinition>
15 Name: "world"
16 Type: String
17
18 - name: with comments
19 input: |
20 # Hello
21 # Hello another
22 type Hello {
23 # World
24 # World another
25 world: String
26 # end of type comments
27 }
28 # end of file comments
29 ast: |
30 <SchemaDocument>
31 Definitions: [Definition]
32 - <Definition>
33 Kind: DefinitionKind("OBJECT")
34 Name: "Hello"
35 Fields: [FieldDefinition]
36 - <FieldDefinition>
37 Name: "world"
38 Type: String
39 AfterDescriptionComment: "# World\n# World another\n"
40 AfterDescriptionComment: "# Hello\n# Hello another\n"
41 EndOfDefinitionComment: "# end of type comments\n"
42 Comment: "# end of file comments\n"
43
44 - name: with comments and description
45 input: |
46 # Hello
47 # Hello another
48 "type description"
49 # Hello after description
50 # Hello after description another
51 type Hello {
52 # World
53 # World another
54 "field description"
55 # World after description
56 # World after description another
57 world: String
58 # end of definition coments
59 # end of definition comments another
60 }
61 ast: |
62 <SchemaDocument>
63 Definitions: [Definition]
64 - <Definition>
65 Kind: DefinitionKind("OBJECT")
66 Description: "type description"
67 Name: "Hello"
68 Fields: [FieldDefinition]
69 - <FieldDefinition>
70 Description: "field description"
71 Name: "world"
72 Type: String
73 BeforeDescriptionComment: "# World\n# World another\n"
74 AfterDescriptionComment: "# World after description\n# World after description another\n"
75 BeforeDescriptionComment: "# Hello\n# Hello another\n"
76 AfterDescriptionComment: "# Hello after description\n# Hello after description another\n"
77 EndOfDefinitionComment: "# end of definition coments\n# end of definition comments another\n"
78
79 - name: with description
80 input: |
81 "Description"
82 type Hello {
83 world: String
84 }
85 ast: |
86 <SchemaDocument>
87 Definitions: [Definition]
88 - <Definition>
89 Kind: DefinitionKind("OBJECT")
90 Description: "Description"
91 Name: "Hello"
92 Fields: [FieldDefinition]
93 - <FieldDefinition>
94 Name: "world"
95 Type: String
96
97 - name: with block description
98 input: |
99 # Before description comment
100 """
101 Description
102 """
103 # Even with comments between them
104 type Hello {
105 world: String
106 }
107 ast: |
108 <SchemaDocument>
109 Definitions: [Definition]
110 - <Definition>
111 Kind: DefinitionKind("OBJECT")
112 Description: "Description"
113 Name: "Hello"
114 Fields: [FieldDefinition]
115 - <FieldDefinition>
116 Name: "world"
117 Type: String
118 BeforeDescriptionComment: "# Before description comment\n"
119 AfterDescriptionComment: "# Even with comments between them\n"
120 - name: with field arg
121 input: |
122 type Hello {
123 world(flag: Boolean): String
124 }
125 ast: |
126 <SchemaDocument>
127 Definitions: [Definition]
128 - <Definition>
129 Kind: DefinitionKind("OBJECT")
130 Name: "Hello"
131 Fields: [FieldDefinition]
132 - <FieldDefinition>
133 Name: "world"
134 Arguments: [ArgumentDefinition]
135 - <ArgumentDefinition>
136 Name: "flag"
137 Type: Boolean
138 Type: String
139
140 - name: with field arg and default value
141 input: |
142 type Hello {
143 world(flag: Boolean = true): String
144 }
145 ast: |
146 <SchemaDocument>
147 Definitions: [Definition]
148 - <Definition>
149 Kind: DefinitionKind("OBJECT")
150 Name: "Hello"
151 Fields: [FieldDefinition]
152 - <FieldDefinition>
153 Name: "world"
154 Arguments: [ArgumentDefinition]
155 - <ArgumentDefinition>
156 Name: "flag"
157 DefaultValue: true
158 Type: Boolean
159 Type: String
160
161 - name: with field list arg
162 input: |
163 type Hello {
164 world(things: [String]): String
165 }
166 ast: |
167 <SchemaDocument>
168 Definitions: [Definition]
169 - <Definition>
170 Kind: DefinitionKind("OBJECT")
171 Name: "Hello"
172 Fields: [FieldDefinition]
173 - <FieldDefinition>
174 Name: "world"
175 Arguments: [ArgumentDefinition]
176 - <ArgumentDefinition>
177 Name: "things"
178 Type: [String]
179 Type: String
180
181 - name: with two args
182 input: |
183 type Hello {
184 world(argOne: Boolean, argTwo: Int): String
185 }
186 ast: |
187 <SchemaDocument>
188 Definitions: [Definition]
189 - <Definition>
190 Kind: DefinitionKind("OBJECT")
191 Name: "Hello"
192 Fields: [FieldDefinition]
193 - <FieldDefinition>
194 Name: "world"
195 Arguments: [ArgumentDefinition]
196 - <ArgumentDefinition>
197 Name: "argOne"
198 Type: Boolean
199 - <ArgumentDefinition>
200 Name: "argTwo"
201 Type: Int
202 Type: String
203 - name: must define one or more fields
204 input: |
205 type Hello {}
206 error:
207 message: "expected at least one definition, found }"
208 locations: [{ line: 1, column: 13 }]
209
210type extensions:
211 - name: Object extension
212 input: |
213 # comment
214 extend type Hello {
215 # comment world
216 world: String
217 # end of definition comment
218 }
219 ast: |
220 <SchemaDocument>
221 Extensions: [Definition]
222 - <Definition>
223 Kind: DefinitionKind("OBJECT")
224 Name: "Hello"
225 Fields: [FieldDefinition]
226 - <FieldDefinition>
227 Name: "world"
228 Type: String
229 AfterDescriptionComment: "# comment world\n"
230 AfterDescriptionComment: "# comment\n"
231 EndOfDefinitionComment: "# end of definition comment\n"
232
233 - name: without any fields
234 input: "extend type Hello implements Greeting"
235 ast: |
236 <SchemaDocument>
237 Extensions: [Definition]
238 - <Definition>
239 Kind: DefinitionKind("OBJECT")
240 Name: "Hello"
241 Interfaces: [string]
242 - "Greeting"
243
244 - name: without fields twice
245 input: |
246 extend type Hello implements Greeting
247 extend type Hello implements SecondGreeting
248 ast: |
249 <SchemaDocument>
250 Extensions: [Definition]
251 - <Definition>
252 Kind: DefinitionKind("OBJECT")
253 Name: "Hello"
254 Interfaces: [string]
255 - "Greeting"
256 - <Definition>
257 Kind: DefinitionKind("OBJECT")
258 Name: "Hello"
259 Interfaces: [string]
260 - "SecondGreeting"
261
262 - name: without anything errors
263 input: "extend type Hello"
264 error:
265 message: "Unexpected <EOF>"
266 locations: [{ line: 1, column: 18 }]
267
268 - name: can have descriptions # hmm, this might not be spec compliant...
269 input: |
270 "Description"
271 extend type Hello {
272 world: String
273 }
274 error:
275 message: 'Unexpected String "Description"'
276 locations: [{ line: 1, column: 2 }]
277
278 - name: can not have descriptions on types
279 input: |
280 extend "Description" type Hello {
281 world: String
282 }
283 error:
284 message: Unexpected String "Description"
285 locations: [{ line: 1, column: 9 }]
286
287 - name: all can have directives
288 input: |
289 extend scalar Foo @deprecated
290 extend type Foo @deprecated
291 extend interface Foo @deprecated
292 extend union Foo @deprecated
293 extend enum Foo @deprecated
294 extend input Foo @deprecated
295 ast: |
296 <SchemaDocument>
297 Extensions: [Definition]
298 - <Definition>
299 Kind: DefinitionKind("SCALAR")
300 Name: "Foo"
301 Directives: [Directive]
302 - <Directive>
303 Name: "deprecated"
304 - <Definition>
305 Kind: DefinitionKind("OBJECT")
306 Name: "Foo"
307 Directives: [Directive]
308 - <Directive>
309 Name: "deprecated"
310 - <Definition>
311 Kind: DefinitionKind("INTERFACE")
312 Name: "Foo"
313 Directives: [Directive]
314 - <Directive>
315 Name: "deprecated"
316 - <Definition>
317 Kind: DefinitionKind("UNION")
318 Name: "Foo"
319 Directives: [Directive]
320 - <Directive>
321 Name: "deprecated"
322 - <Definition>
323 Kind: DefinitionKind("ENUM")
324 Name: "Foo"
325 Directives: [Directive]
326 - <Directive>
327 Name: "deprecated"
328 - <Definition>
329 Kind: DefinitionKind("INPUT_OBJECT")
330 Name: "Foo"
331 Directives: [Directive]
332 - <Directive>
333 Name: "deprecated"
334
335schema definition:
336 - name: simple
337 input: |
338 schema {
339 query: Query
340 }
341 ast: |
342 <SchemaDocument>
343 Schema: [SchemaDefinition]
344 - <SchemaDefinition>
345 OperationTypes: [OperationTypeDefinition]
346 - <OperationTypeDefinition>
347 Operation: Operation("query")
348 Type: "Query"
349
350 - name: with comments and description
351 input: |
352 # before description comment
353 "description"
354 # after description comment
355 schema {
356 # before field comment
357 query: Query
358 # after field comment
359 }
360 ast: |
361 <SchemaDocument>
362 Schema: [SchemaDefinition]
363 - <SchemaDefinition>
364 Description: "description"
365 OperationTypes: [OperationTypeDefinition]
366 - <OperationTypeDefinition>
367 Operation: Operation("query")
368 Type: "Query"
369 Comment: "# before field comment\n"
370 BeforeDescriptionComment: "# before description comment\n"
371 AfterDescriptionComment: "# after description comment\n"
372 EndOfDefinitionComment: "# after field comment\n"
373
374schema extensions:
375 - name: simple
376 input: |
377 extend schema {
378 mutation: Mutation
379 }
380 ast: |
381 <SchemaDocument>
382 SchemaExtension: [SchemaDefinition]
383 - <SchemaDefinition>
384 OperationTypes: [OperationTypeDefinition]
385 - <OperationTypeDefinition>
386 Operation: Operation("mutation")
387 Type: "Mutation"
388
389 - name: with comment and description
390 input: |
391 # before extend comment
392 extend schema {
393 # before field comment
394 mutation: Mutation
395 # after field comment
396 }
397 ast: |
398 <SchemaDocument>
399 SchemaExtension: [SchemaDefinition]
400 - <SchemaDefinition>
401 OperationTypes: [OperationTypeDefinition]
402 - <OperationTypeDefinition>
403 Operation: Operation("mutation")
404 Type: "Mutation"
405 Comment: "# before field comment\n"
406 AfterDescriptionComment: "# before extend comment\n"
407 EndOfDefinitionComment: "# after field comment\n"
408
409 - name: directive only
410 input: "extend schema @directive"
411 ast: |
412 <SchemaDocument>
413 SchemaExtension: [SchemaDefinition]
414 - <SchemaDefinition>
415 Directives: [Directive]
416 - <Directive>
417 Name: "directive"
418
419 - name: without anything errors
420 input: "extend schema"
421 error:
422 message: "Unexpected <EOF>"
423 locations: [{ line: 1, column: 14}]
424
425inheritance:
426 - name: single
427 input: "type Hello implements World { field: String }"
428 ast: |
429 <SchemaDocument>
430 Definitions: [Definition]
431 - <Definition>
432 Kind: DefinitionKind("OBJECT")
433 Name: "Hello"
434 Interfaces: [string]
435 - "World"
436 Fields: [FieldDefinition]
437 - <FieldDefinition>
438 Name: "field"
439 Type: String
440
441 - name: multi
442 input: "type Hello implements Wo & rld { field: String }"
443 ast: |
444 <SchemaDocument>
445 Definitions: [Definition]
446 - <Definition>
447 Kind: DefinitionKind("OBJECT")
448 Name: "Hello"
449 Interfaces: [string]
450 - "Wo"
451 - "rld"
452 Fields: [FieldDefinition]
453 - <FieldDefinition>
454 Name: "field"
455 Type: String
456
457 - name: multi with leading amp
458 input: "type Hello implements & Wo & rld { field: String }"
459 ast: |
460 <SchemaDocument>
461 Definitions: [Definition]
462 - <Definition>
463 Kind: DefinitionKind("OBJECT")
464 Name: "Hello"
465 Interfaces: [string]
466 - "Wo"
467 - "rld"
468 Fields: [FieldDefinition]
469 - <FieldDefinition>
470 Name: "field"
471 Type: String
472
473enums:
474 - name: single value
475 input: "enum Hello { WORLD }"
476 ast: |
477 <SchemaDocument>
478 Definitions: [Definition]
479 - <Definition>
480 Kind: DefinitionKind("ENUM")
481 Name: "Hello"
482 EnumValues: [EnumValueDefinition]
483 - <EnumValueDefinition>
484 Name: "WORLD"
485
486 - name: double value
487 input: "enum Hello { WO, RLD }"
488 ast: |
489 <SchemaDocument>
490 Definitions: [Definition]
491 - <Definition>
492 Kind: DefinitionKind("ENUM")
493 Name: "Hello"
494 EnumValues: [EnumValueDefinition]
495 - <EnumValueDefinition>
496 Name: "WO"
497 - <EnumValueDefinition>
498 Name: "RLD"
499 - name: must define one or more unique enum values
500 input: |
501 enum Hello {}
502 error:
503 message: "expected at least one definition, found }"
504 locations: [{ line: 1, column: 13 }]
505
506interface:
507 - name: simple
508 input: |
509 interface Hello {
510 world: String
511 }
512 ast: |
513 <SchemaDocument>
514 Definitions: [Definition]
515 - <Definition>
516 Kind: DefinitionKind("INTERFACE")
517 Name: "Hello"
518 Fields: [FieldDefinition]
519 - <FieldDefinition>
520 Name: "world"
521 Type: String
522 - name: must define one or more fields
523 input: |
524 interface Hello {}
525 error:
526 message: "expected at least one definition, found }"
527 locations: [{ line: 1, column: 18 }]
528
529 - name: may define intermediate interfaces
530 input: |
531 interface IA {
532 id: ID!
533 }
534
535 interface IIA implements IA {
536 id: ID!
537 }
538
539 type A implements IIA {
540 id: ID!
541 }
542 ast: |
543 <SchemaDocument>
544 Definitions: [Definition]
545 - <Definition>
546 Kind: DefinitionKind("INTERFACE")
547 Name: "IA"
548 Fields: [FieldDefinition]
549 - <FieldDefinition>
550 Name: "id"
551 Type: ID!
552 - <Definition>
553 Kind: DefinitionKind("INTERFACE")
554 Name: "IIA"
555 Interfaces: [string]
556 - "IA"
557 Fields: [FieldDefinition]
558 - <FieldDefinition>
559 Name: "id"
560 Type: ID!
561 - <Definition>
562 Kind: DefinitionKind("OBJECT")
563 Name: "A"
564 Interfaces: [string]
565 - "IIA"
566 Fields: [FieldDefinition]
567 - <FieldDefinition>
568 Name: "id"
569 Type: ID!
570
571unions:
572 - name: simple
573 input: "union Hello = World"
574 ast: |
575 <SchemaDocument>
576 Definitions: [Definition]
577 - <Definition>
578 Kind: DefinitionKind("UNION")
579 Name: "Hello"
580 Types: [string]
581 - "World"
582
583 - name: with two types
584 input: "union Hello = Wo | Rld"
585 ast: |
586 <SchemaDocument>
587 Definitions: [Definition]
588 - <Definition>
589 Kind: DefinitionKind("UNION")
590 Name: "Hello"
591 Types: [string]
592 - "Wo"
593 - "Rld"
594
595 - name: with leading pipe
596 input: "union Hello = | Wo | Rld"
597 ast: |
598 <SchemaDocument>
599 Definitions: [Definition]
600 - <Definition>
601 Kind: DefinitionKind("UNION")
602 Name: "Hello"
603 Types: [string]
604 - "Wo"
605 - "Rld"
606
607 - name: cant be empty
608 input: "union Hello = || Wo | Rld"
609 error:
610 message: "Expected Name, found |"
611 locations: [{ line: 1, column: 16 }]
612
613 - name: cant double pipe
614 input: "union Hello = Wo || Rld"
615 error:
616 message: "Expected Name, found |"
617 locations: [{ line: 1, column: 19 }]
618
619 - name: cant have trailing pipe
620 input: "union Hello = | Wo | Rld |"
621 error:
622 message: "Expected Name, found <EOF>"
623 locations: [{ line: 1, column: 27 }]
624
625scalar:
626 - name: simple
627 input: "scalar Hello"
628 ast: |
629 <SchemaDocument>
630 Definitions: [Definition]
631 - <Definition>
632 Kind: DefinitionKind("SCALAR")
633 Name: "Hello"
634
635input object:
636 - name: simple
637 input: |
638 input Hello {
639 world: String
640 }
641 ast: |
642 <SchemaDocument>
643 Definitions: [Definition]
644 - <Definition>
645 Kind: DefinitionKind("INPUT_OBJECT")
646 Name: "Hello"
647 Fields: [FieldDefinition]
648 - <FieldDefinition>
649 Name: "world"
650 Type: String
651
652 - name: can not have args
653 input: |
654 input Hello {
655 world(foo: Int): String
656 }
657 error:
658 message: "Expected :, found ("
659 locations: [{ line: 2, column: 8 }]
660 - name: must define one or more input fields
661 input: |
662 input Hello {}
663 error:
664 message: "expected at least one definition, found }"
665 locations: [{ line: 1, column: 14 }]
666
667directives:
668 - name: simple
669 input: directive @foo on FIELD
670 ast: |
671 <SchemaDocument>
672 Directives: [DirectiveDefinition]
673 - <DirectiveDefinition>
674 Name: "foo"
675 Locations: [DirectiveLocation]
676 - DirectiveLocation("FIELD")
677 IsRepeatable: false
678
679 - name: executable
680 input: |
681 directive @onQuery on QUERY
682 directive @onMutation on MUTATION
683 directive @onSubscription on SUBSCRIPTION
684 directive @onField on FIELD
685 directive @onFragmentDefinition on FRAGMENT_DEFINITION
686 directive @onFragmentSpread on FRAGMENT_SPREAD
687 directive @onInlineFragment on INLINE_FRAGMENT
688 directive @onVariableDefinition on VARIABLE_DEFINITION
689 ast: |
690 <SchemaDocument>
691 Directives: [DirectiveDefinition]
692 - <DirectiveDefinition>
693 Name: "onQuery"
694 Locations: [DirectiveLocation]
695 - DirectiveLocation("QUERY")
696 IsRepeatable: false
697 - <DirectiveDefinition>
698 Name: "onMutation"
699 Locations: [DirectiveLocation]
700 - DirectiveLocation("MUTATION")
701 IsRepeatable: false
702 - <DirectiveDefinition>
703 Name: "onSubscription"
704 Locations: [DirectiveLocation]
705 - DirectiveLocation("SUBSCRIPTION")
706 IsRepeatable: false
707 - <DirectiveDefinition>
708 Name: "onField"
709 Locations: [DirectiveLocation]
710 - DirectiveLocation("FIELD")
711 IsRepeatable: false
712 - <DirectiveDefinition>
713 Name: "onFragmentDefinition"
714 Locations: [DirectiveLocation]
715 - DirectiveLocation("FRAGMENT_DEFINITION")
716 IsRepeatable: false
717 - <DirectiveDefinition>
718 Name: "onFragmentSpread"
719 Locations: [DirectiveLocation]
720 - DirectiveLocation("FRAGMENT_SPREAD")
721 IsRepeatable: false
722 - <DirectiveDefinition>
723 Name: "onInlineFragment"
724 Locations: [DirectiveLocation]
725 - DirectiveLocation("INLINE_FRAGMENT")
726 IsRepeatable: false
727 - <DirectiveDefinition>
728 Name: "onVariableDefinition"
729 Locations: [DirectiveLocation]
730 - DirectiveLocation("VARIABLE_DEFINITION")
731 IsRepeatable: false
732
733 - name: repeatable
734 input: directive @foo repeatable on FIELD
735 ast: |
736 <SchemaDocument>
737 Directives: [DirectiveDefinition]
738 - <DirectiveDefinition>
739 Name: "foo"
740 Locations: [DirectiveLocation]
741 - DirectiveLocation("FIELD")
742 IsRepeatable: true
743
744 - name: invalid location
745 input: "directive @foo on FIELD | INCORRECT_LOCATION"
746 error:
747 message: 'Unexpected Name "INCORRECT_LOCATION"'
748 locations: [{ line: 1, column: 27 }]
749
750fuzzer:
751 - name: 1
752 input: "type o{d(g:["
753 error:
754 message: 'Expected Name, found <EOF>'
755 locations: [{ line: 1, column: 13 }]
756 - name: 2
757 input: "\"\"\"\r"
758 error:
759 message: 'Unexpected <Invalid>'
760 locations: [{ line: 2, column: 1 }]
View as plain text