@@ -19,6 +19,17 @@ local function getParentField(context, name, count)
19
19
end
20
20
21
21
local visitors = {
22
+ -- <document>
23
+ --
24
+ -- {
25
+ -- kind = 'document',
26
+ -- definitions = list of <definition>,
27
+ -- }
28
+ --
29
+ -- <definition> is one of the following:
30
+ --
31
+ -- * <operation>
32
+ -- * <fragmentDefinition>
22
33
document = {
23
34
enter = function (node , context )
24
35
for _ , definition in ipairs (node .definitions ) do
@@ -35,6 +46,47 @@ local visitors = {
35
46
rules = { rules .uniqueFragmentNames , exit = { rules .noUnusedFragments } }
36
47
},
37
48
49
+ -- <operation>
50
+ --
51
+ -- {
52
+ -- kind = 'operation',
53
+ -- operation = 'query' or 'mutation',
54
+ -- selectionSet = <selectionSet>,
55
+ -- variableDefinitions = list of <variableDefinition> (optional),
56
+ -- directives = list of <directive> (optional),
57
+ -- }
58
+ --
59
+ -- <variableDefinition>
60
+ --
61
+ -- {
62
+ -- kind = 'variableDefinition',
63
+ -- variable = <variable>,
64
+ -- type = <type>,
65
+ -- defaultValue = <value> (optional)
66
+ -- }
67
+ --
68
+ -- <type> is one of the following:
69
+ --
70
+ -- * <namedType>
71
+ -- * <listType>
72
+ -- * <nonNullType>
73
+ --
74
+ -- <namedType>
75
+ --
76
+ -- {
77
+ -- kind = 'namedType',
78
+ -- name = {
79
+ -- kind = 'name',
80
+ -- value = <string>,
81
+ -- },
82
+ -- }
83
+ --
84
+ -- <listType>, <nonNullType>
85
+ --
86
+ -- {
87
+ -- kind = one of ('listType', 'nonNullType'),
88
+ -- type = <type>,
89
+ -- }
38
90
operation = {
39
91
enter = function (node , context )
40
92
table.insert (context .objects , context .schema [node .operation ])
@@ -65,6 +117,18 @@ local visitors = {
65
117
}
66
118
},
67
119
120
+ -- <selectionSet>
121
+ --
122
+ -- {
123
+ -- kind = 'selectionSet',
124
+ -- selections = list of <selection>,
125
+ -- }
126
+ --
127
+ -- <selection> is one of the following:
128
+ --
129
+ -- * <field>
130
+ -- * <fragmentSpread>
131
+ -- * <inlineFragment>
68
132
selectionSet = {
69
133
children = function (node )
70
134
return node .selections
@@ -73,6 +137,22 @@ local visitors = {
73
137
rules = { rules .unambiguousSelections }
74
138
},
75
139
140
+ -- <field>
141
+ --
142
+ -- {
143
+ -- kind = 'field',
144
+ -- selectionSet = <selectionSet> (optional),
145
+ -- alias = <alias> (optional),
146
+ -- arguments = list of <argument> (optional),
147
+ -- directives = list of <directive> (optional),
148
+ -- }
149
+ --
150
+ -- <alias>
151
+ --
152
+ -- {
153
+ -- kind = 'alias',
154
+ -- name = <string>,
155
+ -- }
76
156
field = {
77
157
enter = function (node , context )
78
158
local name = node .name .value
@@ -125,6 +205,14 @@ local visitors = {
125
205
}
126
206
},
127
207
208
+ -- <inlineFragment>
209
+ --
210
+ -- {
211
+ -- kind = 'inlineFragment',
212
+ -- selectionSet = <selectionSet>,
213
+ -- typeCondition = <namedType> (optional),
214
+ -- directives = list of <directive> (optional),
215
+ -- }
128
216
inlineFragment = {
129
217
enter = function (node , context )
130
218
local kind = false
@@ -153,6 +241,16 @@ local visitors = {
153
241
}
154
242
},
155
243
244
+ -- <fragmentSpread>
245
+ --
246
+ -- {
247
+ -- kind = 'fragmentSpread',
248
+ -- name = {
249
+ -- kind = 'name',
250
+ -- value = <string>,
251
+ -- },
252
+ -- directives = list of <directive> (optional),
253
+ -- }
156
254
fragmentSpread = {
157
255
enter = function (node , context )
158
256
context .usedFragments [node .name .value ] = true
@@ -218,6 +316,17 @@ local visitors = {
218
316
}
219
317
},
220
318
319
+ -- <fragmentDefinition>
320
+ --
321
+ -- {
322
+ -- kind = 'fragmentDefinition',
323
+ -- name = {
324
+ -- kind = 'name',
325
+ -- value = <string>,
326
+ -- },
327
+ -- typeCondition = <namedType>,
328
+ -- selectionSet = <selectionSet>,
329
+ -- }
221
330
fragmentDefinition = {
222
331
enter = function (node , context )
223
332
local kind = context .schema :getType (node .typeCondition .name .value ) or false
@@ -245,6 +354,41 @@ local visitors = {
245
354
}
246
355
},
247
356
357
+ -- <argument>
358
+ --
359
+ -- {
360
+ -- kind = 'argument',
361
+ -- name = {
362
+ -- kind = 'name',
363
+ -- value = <string>,
364
+ -- },
365
+ -- value = <value>,
366
+ -- }
367
+ --
368
+ -- <value> is one of the following:
369
+ --
370
+ -- * <variable>
371
+ -- * <inputObject>
372
+ -- * <list>
373
+ -- * <enum>
374
+ -- * <string>
375
+ -- * <boolean>
376
+ -- * <float>
377
+ -- * <int>
378
+ --
379
+ -- <list>
380
+ --
381
+ -- {
382
+ -- kind = 'list',
383
+ -- values = list of <value>,
384
+ -- }
385
+ --
386
+ -- <enum>, <string>, <boolean>, <float>, <int>
387
+ --
388
+ -- {
389
+ -- kind = one of ('enum', 'string', 'boolean', 'float', 'int'),
390
+ -- value = <string>,
391
+ -- }
248
392
argument = {
249
393
enter = function (node , context )
250
394
if context .currentOperation then
@@ -268,6 +412,15 @@ local visitors = {
268
412
rules = { rules .uniqueInputObjectFields }
269
413
},
270
414
415
+ -- <inputObject>
416
+ --
417
+ -- {
418
+ -- kind = 'inputObject',
419
+ -- values = list of {
420
+ -- name = <string>,
421
+ -- value = <value>,
422
+ -- }
423
+ -- }
271
424
inputObject = {
272
425
children = function (node )
273
426
return util .map (node .values or {}, function (value )
@@ -278,12 +431,31 @@ local visitors = {
278
431
rules = { rules .uniqueInputObjectFields }
279
432
},
280
433
434
+ -- <variable>
435
+ --
436
+ -- {
437
+ -- kind = 'variable',
438
+ -- name = {
439
+ -- kind = 'name',
440
+ -- value = <string>,
441
+ -- }
442
+ -- }
281
443
variable = {
282
444
enter = function (node , context )
283
445
context .variableReferences [node .name .value ] = true
284
446
end
285
447
},
286
448
449
+ -- <directive>
450
+ --
451
+ -- {
452
+ -- kind = 'directive',
453
+ -- name = {
454
+ -- kind = 'name',
455
+ -- value = <string>,
456
+ -- },
457
+ -- arguments = list of <argument> (optional),
458
+ -- }
287
459
directive = {
288
460
children = function (node , context )
289
461
return node .arguments
@@ -340,3 +512,5 @@ return function(schema, tree)
340
512
341
513
return visit (tree )
342
514
end
515
+
516
+ -- vim: set ts=2 sw=2 et:
0 commit comments