File: schema_test.yml

package info (click to toggle)
golang-github-vektah-gqlparser 2.5.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,748 kB
  • sloc: javascript: 164; sh: 46; makefile: 10
file content (731 lines) | stat: -rw-r--r-- 18,338 bytes parent folder | download
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
types:
  - name: cannot be redeclared
    input: |
      type A {
        name: String
      }
      type A {
        name: String
      }
    error:
      message: "Cannot redeclare type A."
      locations: [{line: 4, column: 6}]
  - name: cannot be duplicated field at same definition 1
    input: |
      type A {
        name: String
        name: String
      }
    error:
      message: "Field A.name can only be defined once."
      locations: [{line: 3, column: 3}]
  - name: cannot be duplicated field at same definition 2
    input: |
      type A {
        name: String
      }
      extend type A {
        name: String
      }
    error:
      message: "Field A.name can only be defined once."
      locations: [{line: 5, column: 3}]
  - name: cannot be duplicated field at same definition 3
    input: |
      type A {
        name: String
      }
      extend type A {
        age: Int
        age: Int
      }
    error:
      message: "Field A.age can only be defined once."
      locations: [{line: 6, column: 3}]

object types:
  - name: must define one or more fields
    input: |
      directive @D on OBJECT

      # This pattern rejected by parser
      # type InvalidObject1 {}

      type InvalidObject2 @D

      type ValidObject {
        id: ID
      }
      extend type ValidObject @D
      extend type ValidObject {
        b: Int
      }
    error:
      message: 'OBJECT InvalidObject2: must define one or more fields.'
      locations: [{line: 6, column: 6}]
  - name: check reserved names on type name
    input: |
      type __FooBar {
        id: ID
      }
    error:
      message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
      locations: [{line: 1, column: 6}]
  - name: check reserved names on type field
    input: |
      type FooBar {
        __id: ID
      }
    error:
      message: 'Name "__id" must not begin with "__", which is reserved by GraphQL introspection.'
      locations: [{line: 2, column: 3}]

  - name: field argument list must not be empty
    input: |
      type FooBar {
        foo(): ID
      }
    error:
      message: 'expected at least one definition, found )'
      locations: [{line: 2, column: 7}]

  - name: check reserved names on type field argument
    input: |
      type FooBar {
        foo(__bar: ID): ID
      }
    error:
      message: 'Name "__bar" must not begin with "__", which is reserved by GraphQL introspection.'
      locations: [{line: 2, column: 7}]

  - name: must not allow input object as field type
    input: |
      input Input {
        id: ID
      }
      type Query {
        input: Input!
      }
    error:
      message: 'OBJECT Query: field must be one of SCALAR, OBJECT, INTERFACE, UNION, ENUM.'
      locations: [{line: 5, column: 3}]

interfaces:
  - name: must exist
    input: |
      type Thing implements Object {
        id: ID!
      }

      type Query {
        Things: [Thing!]!
      }
    error:
      message: 'Undefined type "Object".'
      locations: [{line: 1, column: 6}]

  - name: must be an interface
    input: |
      type Thing implements Object {
        id: ID!
      }

      type Query {
        Things: [Thing!]!
      }

      type Object {
        name: String
      }
    error:
      message: '"Object" is a non interface type OBJECT.'
      locations: [{line: 1, column: 6}]

  - name: must define one or more fields
    input: |
      directive @D on INTERFACE

      # This pattern rejected by parser
      # interface InvalidInterface1 {}

      interface InvalidInterface2 @D

      interface ValidInterface {
        id: ID
      }
      extend interface ValidInterface @D
      extend interface ValidInterface {
        b: Int
      }
    error:
      message: 'INTERFACE InvalidInterface2: must define one or more fields.'
      locations: [{line: 6, column: 11}]

  - name: check reserved names on type name
    input: |
      interface __FooBar {
        id: ID
      }
    error:
      message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
      locations: [{line: 1, column: 11}]

  - name: must not allow input object as field type
    input: |
      input Input {
        id: ID
      }
      type Query {
        foo: Foo!
      }
      interface Foo {
        input: Input!
      }
    error:
      message: 'INTERFACE Foo: field must be one of SCALAR, OBJECT, INTERFACE, UNION, ENUM.'
      locations: [{line: 8, column: 3}]

  - name: must have all fields from interface
    input: |
      type Bar implements BarInterface {
          someField: Int!
      }

      interface BarInterface {
          id: ID!
      }
    error:
      message: 'For Bar to implement BarInterface it must have a field called id.'
      locations: [{line: 1, column: 6}]

  - name: must have same type of fields
    input: |
      type Bar implements BarInterface {
          id: Int!
      }

      interface BarInterface {
          id: ID!
      }
    error:
      message: 'For Bar to implement BarInterface the field id must have type ID!.'
      locations: [{line: 2, column: 5}]

  - name: must have all required arguments
    input: |
      type Bar implements BarInterface {
          id: ID!
      }

      interface BarInterface {
          id(ff: Int!): ID!
      }
    error:
      message: 'For Bar to implement BarInterface the field id must have the same arguments but it is missing ff.'
      locations: [{line: 2, column: 5}]

  - name: must have same argument types
    input: |
      type Bar implements BarInterface {
          id(ff: ID!): ID!
      }

      interface BarInterface {
          id(ff: Int!): ID!
      }
    error:
      message: 'For Bar to implement BarInterface the field id must have the same arguments but ff has the wrong type.'
      locations: [{line: 2, column: 8}]

  - name: may defined additional nullable arguments
    input: |
      type Bar implements BarInterface {
          id(opt: Int): ID!
      }

      interface BarInterface {
          id: ID!
      }

  - name: may defined additional required arguments with defaults
    input: |
      type Bar implements BarInterface {
          id(opt: Int! = 1): ID!
      }

      interface BarInterface {
          id: ID!
      }

  - name: must not define additional required arguments without defaults
    input: |
      type Bar implements BarInterface {
          id(opt: Int!): ID!
      }

      interface BarInterface {
          id: ID!
      }
    error:
      message: 'For Bar to implement BarInterface any additional arguments on id must be optional or have a default value but opt is required.'
      locations: [{line: 2, column: 8}]

  - name: can have covariant argument types
    input: |
      union U = A|B

      type A { name: String }
      type B { name: String }

      type Bar implements BarInterface {
          f: A!
      }

      interface BarInterface {
          f: U!
      }

  - name: may define intermediate interfaces
    input: |
      interface IA {
          id: ID!
      }

      interface IIA implements IA {
          id: ID!
      }

      type A implements IIA & IA {
          id: ID!
      }

  - name: Type Foo must implement Baz because it is implemented by Bar
    input: |
      interface Baz {
          baz: String
      }

      interface Bar implements Baz {
          bar: String
          baz: String
      }

      type Foo implements Bar {
          foo: String
          bar: String
          baz: String
      }
    error:
      message: 'Type Foo must implement Baz because it is implemented by Bar.'
      locations: [{line: 10, column: 6}]

  - name: circular reference error
    input: |
      interface Circular1 implements Circular2 {
        id: ID!
      }

      interface Circular2 implements Circular1 {
        id: ID!
      }
    error:
      message: 'Type Circular1 cannot implement Circular2 because it would create a circular reference.'
      locations: [{line: 1, column: 11}]

inputs:
  - name: must define one or more input fields
    input: |
      directive @D on INPUT_OBJECT

      # This pattern rejected by parser
      # input InvalidInput1 {}

      input InvalidInput2 @D

      input ValidInput {
        id: ID
      }
      extend input ValidInput @D
      extend input ValidInput {
        b: Int
      }
    error:
      message: 'INPUT_OBJECT InvalidInput2: must define one or more input fields.'
      locations: [{line: 6, column: 7}]
  - name: check reserved names on type name
    input: |
      input __FooBar {
        id: ID
      }
    error:
      message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
      locations: [{line: 1, column: 7}]

  - name: fields cannot be Objects
    input: |
      type Object { id: ID }
      input Foo { a: Object! }
    error:
      message: 'OBJECT a: field must be one of SCALAR, ENUM, INPUT_OBJECT.'
      locations: [{line: 2, column: 13}]

  - name: fields cannot be Interfaces
    input: |
      interface Interface { id: ID! }
      input Foo { a: Interface! }
    error:
      message: 'INTERFACE a: field must be one of SCALAR, ENUM, INPUT_OBJECT.'
      locations: [{line: 2, column: 13}]

  - name: fields cannot be Unions
    input: |
      type Object { id: ID }
      union Union = Object
      input Foo { a: Union! }
    error:
      message: 'UNION a: field must be one of SCALAR, ENUM, INPUT_OBJECT.'
      locations: [{line: 3, column: 13}]

args:
  - name: Valid arg types
    input: |
        input Input { id: ID }
        enum Enum { A }
        scalar Scalar

        type Query {
          f(a: Input, b: Scalar, c: Enum): Boolean!
        }

  - name: Objects not allowed
    input: |
      type Object { id: ID }
      type Query { f(a: Object): Boolean! }

    error:
      message: 'cannot use Object as argument a because OBJECT is not a valid input type'
      locations: [{line: 2, column: 16}]

  - name: Union not allowed
    input: |
      type Object { id: ID }
      union Union = Object
      type Query { f(a: Union): Boolean! }

    error:
      message: 'cannot use Union as argument a because UNION is not a valid input type'
      locations: [{line: 3, column: 16}]

  - name: Interface not allowed
    input: |
      interface Interface { id: ID }
      type Query { f(a: Interface): Boolean! }

    error:
      message: 'cannot use Interface as argument a because INTERFACE is not a valid input type'
      locations: [{line: 2, column: 16}]

enums:
  - name: must define one or more unique enum values
    input: |
      directive @D on ENUM

      # This pattern rejected by parser
      # enum InvalidEmum1 {}

      enum InvalidEnum2 @D

      enum ValidEnum {
        FOO
      }
      extend enum ValidEnum @D
      extend enum ValidEnum {
        BAR
      }
    error:
      message: 'ENUM InvalidEnum2: must define one or more unique enum values.'
      locations: [{line: 6, column: 6}]
  - name: check reserved names on type name
    input: |
      enum __FooBar {
        A
        B
      }
    error:
      message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
      locations: [{line: 1, column: 6}]

unions:
  - name: union types must be defined
    input: |
      union Foo = Bar | Baz
      type Bar {
        id: ID
      }
    error:
      message: "Undefined type \"Baz\"."
      locations: [{line: 1, column: 7}]
  - name: union types must be objects
    input: |
      union Foo = Baz
      interface Baz {
        id: ID
      }
    error:
      message: "UNION type \"Baz\" must be OBJECT."
      locations: [{line: 1, column: 7}]

  - name: unions of pure type extensions are valid
    input: |

      type Review {
          body: String!
          author: User! @provides(fields: "username")
          product: Product!
      }

      extend type User @key(fields: "id") {
        id: ID! @external
        reviews: [Review]
      }

      extend type Product @key(fields: "upc") {
        upc: String! @external
        reviews: [Review]
      }

      union Foo = User | Product
      scalar _Any
      scalar _FieldSet
      directive @external on FIELD_DEFINITION
      directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
      directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
      directive @key(fields: _FieldSet!) on OBJECT | INTERFACE
      directive @extends on OBJECT



type extensions:
  - name: can extend non existant types
    input: |
      extend type A {
        name: String
      }


  - name: cannot extend incorret type existant types
    input: |
      scalar A
      extend type A {
        name: String
      }
    error:
      message: "Cannot extend type A because the base type is a SCALAR, not OBJECT."
      locations: [{line: 2, column: 13}]

directives:
  - name: cannot redeclare directives
    input: |
      directive @A on FIELD_DEFINITION
      directive @A on FIELD_DEFINITION
    error:
      message: "Cannot redeclare directive A."
      locations: [{line: 2, column: 12}]

  - name: can redeclare builtin directives
    input: |
      directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
      directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT

  - name: must be declared (type)
    input: |
      type User @foo {
        name: String
      }
    error:
      message: "Undefined directive foo."
      locations: [{line: 1, column: 12}]

  - name: must be declared (field)
    input: |
      type User {
        name: String @foo
      }
    error:
      message: "Undefined directive foo."
      locations: [{line: 2, column: 17}]

  - name: must be declared (enum)
    input: |
      enum Unit {
        METER @foo
      }
    error:
      message: "Undefined directive foo."
      locations: [{line: 2, column: 10}]

  - name: cannot be self-referential
    input: |
      directive @A(foo: Int! @A) on FIELD_DEFINITION
    error:
      message: "Directive A cannot refer to itself."
      locations: [{line: 1, column: 25}]
  - name: check reserved names on type name
    input: |
      directive @__A on FIELD_DEFINITION
    error:
      message: 'Name "__A" must not begin with "__", which is reserved by GraphQL introspection.'
      locations: [{line: 1, column: 12}]

  - name: Valid arg types
    input: |
      input Input { id: ID }
      enum Enum { A }
      scalar Scalar

      directive @A(a: Input, b: Scalar, c: Enum) on FIELD_DEFINITION

  - name: Objects not allowed
    input: |
      type Object { id: ID }
      directive @A(a: Object) on FIELD_DEFINITION

    error:
      message: 'cannot use Object as argument a because OBJECT is not a valid input type'
      locations: [{line: 2, column: 14}]

  - name: Union not allowed
    input: |
      type Object { id: ID }
      union Union = Object
      directive @A(a: Union) on FIELD_DEFINITION

    error:
      message: 'cannot use Union as argument a because UNION is not a valid input type'
      locations: [{line: 3, column: 14}]

  - name: Interface not allowed
    input: |
      interface Interface { id: ID }
      directive @A(a: Interface) on FIELD_DEFINITION

    error:
      message: 'cannot use Interface as argument a because INTERFACE is not a valid input type'
      locations: [{line: 2, column: 14}]

  - name: Invalid location usage not allowed
    input: |
      directive @test on FIELD_DEFINITION
      input I1 @test { f: String }

    error:
      message: 'Directive test is not applicable on INPUT_OBJECT.'
      locations: [{line: 2, column: 11}]

  - name: Valid location usage
    input: |
      directive @testInputField on INPUT_FIELD_DEFINITION
      directive @testField on FIELD_DEFINITION
      directive @inp on INPUT_OBJECT
      input I1 @inp { f: String @testInputField }
      type P { name: String @testField }
      interface I { id: ID @testField }

  - name: Invalid directive argument not allowed
    input: |
      directive @foo(bla: Int!) on FIELD_DEFINITION
      type P {f: Int @foo(foobla: 11)}
    
    error:
      message: 'Undefined argument foobla for directive foo.'
      locations: [{line: 2, column: 21}]

  - name: non-null argument must be provided
    input: |
      directive @foo(bla: Int!) on FIELD_DEFINITION
      type P {f: Int @foo }
    
    error:
      message: 'Argument bla for directive foo cannot be null.'
      locations: [{line: 2, column: 17}]

  - name: non-null argument must not be null
    input: |
      directive @foo(bla: Int!) on FIELD_DEFINITION
      type P {f: Int @foo(bla: null) }
    
    error:
      message: 'Argument bla for directive foo cannot be null.'
      locations: [{line: 2, column: 17}]

entry points:
  - name: multiple schema entry points
    input: |
      schema {
        query: Query
      }
      schema {
        query: Query
      }
      scalar Query
    error:
      message: "Cannot have multiple schema entry points, consider schema extensions instead."
      locations: [{line: 4, column: 8}]

  - name: Undefined schema entrypoint
    input: |
      schema {
        query: Query
      }
    error:
      message: "Schema root query refers to a type Query that does not exist."
      locations: [{line: 2, column: 3}]

entry point extensions:
  - name: Undefined schema entrypoint
    input: |
      schema {
        query: Query
      }
      scalar Query
      extend schema {
        mutation: Mutation
      }
    error:
      message: "Schema root mutation refers to a type Mutation that does not exist."
      locations: [{line: 6, column: 3}]

type references:
  - name: Field types
    input: |
      type User {
        posts: Post
      }
    error:
      message: "Undefined type Post."
      locations: [{line: 2, column: 10}]

  - name: Arg types
    input: |
      type User {
        posts(foo: FooBar): String
      }
    error:
      message: "Undefined type FooBar."
      locations: [{line: 2, column: 14}]

  - name: Directive arg types
    input: |
      directive @Foo(foo: FooBar) on FIELD_DEFINITION

    error:
      message: "Undefined type FooBar."
      locations: [{line: 1, column: 21}]

  - name: Invalid enum value
    input: |
      enum Enum { true }

    error:
      message: "ENUM Enum: non-enum value true."
      locations: [{line: 1, column: 6}]