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 description
19 input: |
20 "Description"
21 type Hello {
22 world: String
23 }
24 ast: |
25 <SchemaDocument>
26 Definitions: [Definition]
27 - <Definition>
28 Kind: DefinitionKind("OBJECT")
29 Description: "Description"
30 Name: "Hello"
31 Fields: [FieldDefinition]
32 - <FieldDefinition>
33 Name: "world"
34 Type: String
35
36 - name: with block description
37 input: |
38 """
39 Description
40 """
41 # Even with comments between them
42 type Hello {
43 world: String
44 }
45 ast: |
46 <SchemaDocument>
47 Definitions: [Definition]
48 - <Definition>
49 Kind: DefinitionKind("OBJECT")
50 Description: "Description"
51 Name: "Hello"
52 Fields: [FieldDefinition]
53 - <FieldDefinition>
54 Name: "world"
55 Type: String
56 - name: with field arg
57 input: |
58 type Hello {
59 world(flag: Boolean): String
60 }
61 ast: |
62 <SchemaDocument>
63 Definitions: [Definition]
64 - <Definition>
65 Kind: DefinitionKind("OBJECT")
66 Name: "Hello"
67 Fields: [FieldDefinition]
68 - <FieldDefinition>
69 Name: "world"
70 Arguments: [ArgumentDefinition]
71 - <ArgumentDefinition>
72 Name: "flag"
73 Type: Boolean
74 Type: String
75
76 - name: with field arg and default value
77 input: |
78 type Hello {
79 world(flag: Boolean = true): String
80 }
81 ast: |
82 <SchemaDocument>
83 Definitions: [Definition]
84 - <Definition>
85 Kind: DefinitionKind("OBJECT")
86 Name: "Hello"
87 Fields: [FieldDefinition]
88 - <FieldDefinition>
89 Name: "world"
90 Arguments: [ArgumentDefinition]
91 - <ArgumentDefinition>
92 Name: "flag"
93 DefaultValue: true
94 Type: Boolean
95 Type: String
96
97 - name: with field list arg
98 input: |
99 type Hello {
100 world(things: [String]): String
101 }
102 ast: |
103 <SchemaDocument>
104 Definitions: [Definition]
105 - <Definition>
106 Kind: DefinitionKind("OBJECT")
107 Name: "Hello"
108 Fields: [FieldDefinition]
109 - <FieldDefinition>
110 Name: "world"
111 Arguments: [ArgumentDefinition]
112 - <ArgumentDefinition>
113 Name: "things"
114 Type: [String]
115 Type: String
116
117 - name: with two args
118 input: |
119 type Hello {
120 world(argOne: Boolean, argTwo: Int): String
121 }
122 ast: |
123 <SchemaDocument>
124 Definitions: [Definition]
125 - <Definition>
126 Kind: DefinitionKind("OBJECT")
127 Name: "Hello"
128 Fields: [FieldDefinition]
129 - <FieldDefinition>
130 Name: "world"
131 Arguments: [ArgumentDefinition]
132 - <ArgumentDefinition>
133 Name: "argOne"
134 Type: Boolean
135 - <ArgumentDefinition>
136 Name: "argTwo"
137 Type: Int
138 Type: String
139
140type extensions:
141 - name: Object extension
142 input: |
143 extend type Hello {
144 world: String
145 }
146 ast: |
147 <SchemaDocument>
148 Extensions: [Definition]
149 - <Definition>
150 Kind: DefinitionKind("OBJECT")
151 Name: "Hello"
152 Fields: [FieldDefinition]
153 - <FieldDefinition>
154 Name: "world"
155 Type: String
156
157 - name: without any fields
158 input: "extend type Hello implements Greeting"
159 ast: |
160 <SchemaDocument>
161 Extensions: [Definition]
162 - <Definition>
163 Kind: DefinitionKind("OBJECT")
164 Name: "Hello"
165 Interfaces: [string]
166 - "Greeting"
167
168 - name: without fields twice
169 input: |
170 extend type Hello implements Greeting
171 extend type Hello implements SecondGreeting
172 ast: |
173 <SchemaDocument>
174 Extensions: [Definition]
175 - <Definition>
176 Kind: DefinitionKind("OBJECT")
177 Name: "Hello"
178 Interfaces: [string]
179 - "Greeting"
180 - <Definition>
181 Kind: DefinitionKind("OBJECT")
182 Name: "Hello"
183 Interfaces: [string]
184 - "SecondGreeting"
185
186 - name: without anything errors
187 input: "extend type Hello"
188 error:
189 message: "Unexpected <EOF>"
190 locations: [{ line: 1, column: 18 }]
191
192 - name: can have descriptions # hmm, this might not be spec compliant...
193 input: |
194 "Description"
195 extend type Hello {
196 world: String
197 }
198 error:
199 message: 'Unexpected String "Description"'
200 locations: [{ line: 1, column: 2 }]
201
202 - name: can not have descriptions on types
203 input: |
204 extend "Description" type Hello {
205 world: String
206 }
207 error:
208 message: Unexpected String "Description"
209 locations: [{ line: 1, column: 9 }]
210
211schema definition:
212 - name: simple
213 input: |
214 schema {
215 query: Query
216 }
217 ast: |
218 <SchemaDocument>
219 Schema: [SchemaDefinition]
220 - <SchemaDefinition>
221 OperationTypes: [OperationTypeDefinition]
222 - <OperationTypeDefinition>
223 Operation: Operation("query")
224 Type: "Query"
225
226schema extensions:
227 - name: simple
228 input: |
229 extend schema {
230 mutation: Mutation
231 }
232 ast: |
233 <SchemaDocument>
234 SchemaExtension: [SchemaDefinition]
235 - <SchemaDefinition>
236 OperationTypes: [OperationTypeDefinition]
237 - <OperationTypeDefinition>
238 Operation: Operation("mutation")
239 Type: "Mutation"
240
241 - name: directive only
242 input: "extend schema @directive"
243 ast: |
244 <SchemaDocument>
245 SchemaExtension: [SchemaDefinition]
246 - <SchemaDefinition>
247 Directives: [Directive]
248 - <Directive>
249 Name: "directive"
250
251 - name: without anything errors
252 input: "extend schema"
253 error:
254 message: "Unexpected <EOF>"
255 locations: [{ line: 1, column: 14}]
256
257type extensions:
258 - name: all can have directives
259 input: |
260 extend scalar Foo @deprecated
261 extend type Foo @deprecated
262 extend interface Foo @deprecated
263 extend union Foo @deprecated
264 extend enum Foo @deprecated
265 extend input Foo @deprecated
266 ast: |
267 <SchemaDocument>
268 Extensions: [Definition]
269 - <Definition>
270 Kind: DefinitionKind("SCALAR")
271 Name: "Foo"
272 Directives: [Directive]
273 - <Directive>
274 Name: "deprecated"
275 - <Definition>
276 Kind: DefinitionKind("OBJECT")
277 Name: "Foo"
278 Directives: [Directive]
279 - <Directive>
280 Name: "deprecated"
281 - <Definition>
282 Kind: DefinitionKind("INTERFACE")
283 Name: "Foo"
284 Directives: [Directive]
285 - <Directive>
286 Name: "deprecated"
287 - <Definition>
288 Kind: DefinitionKind("UNION")
289 Name: "Foo"
290 Directives: [Directive]
291 - <Directive>
292 Name: "deprecated"
293 - <Definition>
294 Kind: DefinitionKind("ENUM")
295 Name: "Foo"
296 Directives: [Directive]
297 - <Directive>
298 Name: "deprecated"
299 - <Definition>
300 Kind: DefinitionKind("INPUT_OBJECT")
301 Name: "Foo"
302 Directives: [Directive]
303 - <Directive>
304 Name: "deprecated"
305
306
307inheritance:
308 - name: single
309 input: "type Hello implements World { field: String }"
310 ast: |
311 <SchemaDocument>
312 Definitions: [Definition]
313 - <Definition>
314 Kind: DefinitionKind("OBJECT")
315 Name: "Hello"
316 Interfaces: [string]
317 - "World"
318 Fields: [FieldDefinition]
319 - <FieldDefinition>
320 Name: "field"
321 Type: String
322
323 - name: multi
324 input: "type Hello implements Wo & rld { field: String }"
325 ast: |
326 <SchemaDocument>
327 Definitions: [Definition]
328 - <Definition>
329 Kind: DefinitionKind("OBJECT")
330 Name: "Hello"
331 Interfaces: [string]
332 - "Wo"
333 - "rld"
334 Fields: [FieldDefinition]
335 - <FieldDefinition>
336 Name: "field"
337 Type: String
338
339 - name: multi with leading amp
340 input: "type Hello implements & Wo & rld { field: String }"
341 ast: |
342 <SchemaDocument>
343 Definitions: [Definition]
344 - <Definition>
345 Kind: DefinitionKind("OBJECT")
346 Name: "Hello"
347 Interfaces: [string]
348 - "Wo"
349 - "rld"
350 Fields: [FieldDefinition]
351 - <FieldDefinition>
352 Name: "field"
353 Type: String
354
355enums:
356 - name: single value
357 input: "enum Hello { WORLD }"
358 ast: |
359 <SchemaDocument>
360 Definitions: [Definition]
361 - <Definition>
362 Kind: DefinitionKind("ENUM")
363 Name: "Hello"
364 EnumValues: [EnumValueDefinition]
365 - <EnumValueDefinition>
366 Name: "WORLD"
367
368 - name: double value
369 input: "enum Hello { WO, RLD }"
370 ast: |
371 <SchemaDocument>
372 Definitions: [Definition]
373 - <Definition>
374 Kind: DefinitionKind("ENUM")
375 Name: "Hello"
376 EnumValues: [EnumValueDefinition]
377 - <EnumValueDefinition>
378 Name: "WO"
379 - <EnumValueDefinition>
380 Name: "RLD"
381
382interface:
383 - name: simple
384 input: |
385 interface Hello {
386 world: String
387 }
388 ast: |
389 <SchemaDocument>
390 Definitions: [Definition]
391 - <Definition>
392 Kind: DefinitionKind("INTERFACE")
393 Name: "Hello"
394 Fields: [FieldDefinition]
395 - <FieldDefinition>
396 Name: "world"
397 Type: String
398
399unions:
400 - name: simple
401 input: "union Hello = World"
402 ast: |
403 <SchemaDocument>
404 Definitions: [Definition]
405 - <Definition>
406 Kind: DefinitionKind("UNION")
407 Name: "Hello"
408 Types: [string]
409 - "World"
410
411 - name: with two types
412 input: "union Hello = Wo | Rld"
413 ast: |
414 <SchemaDocument>
415 Definitions: [Definition]
416 - <Definition>
417 Kind: DefinitionKind("UNION")
418 Name: "Hello"
419 Types: [string]
420 - "Wo"
421 - "Rld"
422
423 - name: with leading pipe
424 input: "union Hello = | Wo | Rld"
425 ast: |
426 <SchemaDocument>
427 Definitions: [Definition]
428 - <Definition>
429 Kind: DefinitionKind("UNION")
430 Name: "Hello"
431 Types: [string]
432 - "Wo"
433 - "Rld"
434
435 - name: cant be empty
436 input: "union Hello = || Wo | Rld"
437 error:
438 message: "Expected Name, found |"
439 locations: [{ line: 1, column: 16 }]
440
441 - name: cant double pipe
442 input: "union Hello = Wo || Rld"
443 error:
444 message: "Expected Name, found |"
445 locations: [{ line: 1, column: 19 }]
446
447 - name: cant have trailing pipe
448 input: "union Hello = | Wo | Rld |"
449 error:
450 message: "Expected Name, found <EOF>"
451 locations: [{ line: 1, column: 27 }]
452
453scalar:
454 - name: simple
455 input: "scalar Hello"
456 ast: |
457 <SchemaDocument>
458 Definitions: [Definition]
459 - <Definition>
460 Kind: DefinitionKind("SCALAR")
461 Name: "Hello"
462
463input object:
464 - name: simple
465 input: |
466 input Hello {
467 world: String
468 }
469 ast: |
470 <SchemaDocument>
471 Definitions: [Definition]
472 - <Definition>
473 Kind: DefinitionKind("INPUT_OBJECT")
474 Name: "Hello"
475 Fields: [FieldDefinition]
476 - <FieldDefinition>
477 Name: "world"
478 Type: String
479
480 - name: can not have args
481 input: |
482 input Hello {
483 world(foo: Int): String
484 }
485 error:
486 message: "Expected :, found ("
487 locations: [{ line: 2, column: 8 }]
488
489directives:
490 - name: simple
491 input: directive @foo on FIELD
492 ast: |
493 <SchemaDocument>
494 Directives: [DirectiveDefinition]
495 - <DirectiveDefinition>
496 Name: "foo"
497 Locations: [DirectiveLocation]
498 - DirectiveLocation("FIELD")
499
500 - name: invalid location
501 input: "directive @foo on FIELD | INCORRECT_LOCATION"
502 error:
503 message: 'Unexpected Name "INCORRECT_LOCATION"'
504 locations: [{ line: 1, column: 27 }]
505