aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/vektah/gqlparser/validator/schema_test.yml
blob: abc8dd7e5c3add3fb69cb32e136517c2bf5196c7 (plain) (blame)
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
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 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: 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}]

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 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}]

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 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}]

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 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}]

type extensions:
  - name: cannot extend non existant types
    input: |
      extend type A {
        name: String
      }
    error:
      message: "Cannot extend type A because it does not exist."
      locations: [{line: 1, column: 13}]

  - 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: must be declared
    input: |
      type User {
        name: String @foo
      }
    error:
      message: "Undefined directive foo."
      locations: [{line: 2, column: 17}]

  - 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}]

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}]