graphql 1.10.2 → 1.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/graphql/core.rb +10 -2
- data/lib/generators/graphql/templates/schema.erb +1 -0
- data/lib/graphql/define/defined_object_proxy.rb +1 -1
- data/lib/graphql/define/instance_definable.rb +1 -1
- data/lib/graphql/execution/interpreter.rb +3 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +25 -0
- data/lib/graphql/execution/interpreter/runtime.rb +37 -121
- data/lib/graphql/field.rb +1 -1
- data/lib/graphql/language/nodes.rb +41 -83
- data/lib/graphql/language/parser.rb +96 -96
- data/lib/graphql/language/parser.y +96 -96
- data/lib/graphql/pagination/connections.rb +21 -5
- data/lib/graphql/query/null_context.rb +5 -1
- data/lib/graphql/query/variables.rb +9 -3
- data/lib/graphql/schema.rb +18 -2
- data/lib/graphql/schema/build_from_definition.rb +15 -1
- data/lib/graphql/schema/enum.rb +4 -1
- data/lib/graphql/schema/field.rb +11 -0
- data/lib/graphql/schema/field/connection_extension.rb +2 -1
- data/lib/graphql/schema/input_object.rb +21 -38
- data/lib/graphql/schema/member/base_dsl_methods.rb +11 -4
- data/lib/graphql/schema/member/has_arguments.rb +53 -2
- data/lib/graphql/schema/member/has_ast_node.rb +4 -1
- data/lib/graphql/schema/member/has_fields.rb +1 -1
- data/lib/graphql/schema/resolver.rb +2 -2
- data/lib/graphql/schema/resolver/has_payload_type.rb +3 -1
- data/lib/graphql/schema/warden.rb +10 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +0 -1
- data/lib/graphql/subscriptions.rb +14 -9
- data/lib/graphql/subscriptions/subscription_root.rb +2 -1
- data/lib/graphql/version.rb +1 -1
- metadata +4 -3
@@ -2,10 +2,10 @@ class GraphQL::Language::Parser
|
|
2
2
|
rule
|
3
3
|
target: document
|
4
4
|
|
5
|
-
document: definitions_list {
|
5
|
+
document: definitions_list { result = make_node(:Document, definitions: val[0])}
|
6
6
|
|
7
7
|
definitions_list:
|
8
|
-
definition {
|
8
|
+
definition { result = [val[0]]}
|
9
9
|
| definitions_list definition { val[0] << val[1] }
|
10
10
|
|
11
11
|
definition:
|
@@ -19,7 +19,7 @@ rule
|
|
19
19
|
|
20
20
|
operation_definition:
|
21
21
|
operation_type operation_name_opt variable_definitions_opt directives_list_opt selection_set {
|
22
|
-
|
22
|
+
result = make_node(
|
23
23
|
:OperationDefinition, {
|
24
24
|
operation_type: val[0],
|
25
25
|
name: val[1],
|
@@ -31,7 +31,7 @@ rule
|
|
31
31
|
)
|
32
32
|
}
|
33
33
|
| LCURLY selection_list RCURLY {
|
34
|
-
|
34
|
+
result = make_node(
|
35
35
|
:OperationDefinition, {
|
36
36
|
operation_type: "query",
|
37
37
|
selections: val[1],
|
@@ -40,7 +40,7 @@ rule
|
|
40
40
|
)
|
41
41
|
}
|
42
42
|
| LCURLY RCURLY {
|
43
|
-
|
43
|
+
result = make_node(
|
44
44
|
:OperationDefinition, {
|
45
45
|
operation_type: "query",
|
46
46
|
selections: [],
|
@@ -55,20 +55,20 @@ rule
|
|
55
55
|
| SUBSCRIPTION
|
56
56
|
|
57
57
|
operation_name_opt:
|
58
|
-
/* none */ {
|
58
|
+
/* none */ { result = nil }
|
59
59
|
| name
|
60
60
|
|
61
61
|
variable_definitions_opt:
|
62
|
-
/* none */ {
|
63
|
-
| LPAREN variable_definitions_list RPAREN {
|
62
|
+
/* none */ { result = EMPTY_ARRAY }
|
63
|
+
| LPAREN variable_definitions_list RPAREN { result = val[1] }
|
64
64
|
|
65
65
|
variable_definitions_list:
|
66
|
-
variable_definition {
|
66
|
+
variable_definition { result = [val[0]] }
|
67
67
|
| variable_definitions_list variable_definition { val[0] << val[1] }
|
68
68
|
|
69
69
|
variable_definition:
|
70
70
|
VAR_SIGN name COLON type default_value_opt {
|
71
|
-
|
71
|
+
result = make_node(:VariableDefinition, {
|
72
72
|
name: val[1],
|
73
73
|
type: val[3],
|
74
74
|
default_value: val[4],
|
@@ -77,26 +77,26 @@ rule
|
|
77
77
|
}
|
78
78
|
|
79
79
|
type:
|
80
|
-
nullable_type {
|
81
|
-
| nullable_type BANG {
|
80
|
+
nullable_type { result = val[0] }
|
81
|
+
| nullable_type BANG { result = make_node(:NonNullType, of_type: val[0]) }
|
82
82
|
|
83
83
|
nullable_type:
|
84
|
-
name {
|
85
|
-
| LBRACKET type RBRACKET {
|
84
|
+
name { result = make_node(:TypeName, name: val[0])}
|
85
|
+
| LBRACKET type RBRACKET { result = make_node(:ListType, of_type: val[1]) }
|
86
86
|
|
87
87
|
default_value_opt:
|
88
|
-
/* none */ {
|
89
|
-
| EQUALS literal_value {
|
88
|
+
/* none */ { result = nil }
|
89
|
+
| EQUALS literal_value { result = val[1] }
|
90
90
|
|
91
91
|
selection_set:
|
92
|
-
LCURLY selection_list RCURLY {
|
92
|
+
LCURLY selection_list RCURLY { result = val[1] }
|
93
93
|
|
94
94
|
selection_set_opt:
|
95
|
-
/* none */ {
|
96
|
-
| selection_set {
|
95
|
+
/* none */ { result = EMPTY_ARRAY }
|
96
|
+
| selection_set { result = val[0] }
|
97
97
|
|
98
98
|
selection_list:
|
99
|
-
selection {
|
99
|
+
selection { result = [result] }
|
100
100
|
| selection_list selection { val[0] << val[1] }
|
101
101
|
|
102
102
|
selection:
|
@@ -106,7 +106,7 @@ rule
|
|
106
106
|
|
107
107
|
field:
|
108
108
|
name arguments_opt directives_list_opt selection_set_opt {
|
109
|
-
|
109
|
+
result = make_node(
|
110
110
|
:Field, {
|
111
111
|
name: val[0],
|
112
112
|
arguments: val[1],
|
@@ -117,7 +117,7 @@ rule
|
|
117
117
|
)
|
118
118
|
}
|
119
119
|
| name COLON name arguments_opt directives_list_opt selection_set_opt {
|
120
|
-
|
120
|
+
result = make_node(
|
121
121
|
:Field, {
|
122
122
|
alias: val[0],
|
123
123
|
name: val[2],
|
@@ -160,29 +160,29 @@ rule
|
|
160
160
|
| schema_keyword
|
161
161
|
|
162
162
|
enum_value_definition:
|
163
|
-
description_opt enum_name directives_list_opt {
|
163
|
+
description_opt enum_name directives_list_opt { result = make_node(:EnumValueDefinition, name: val[1], directives: val[2], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1]) }
|
164
164
|
|
165
165
|
enum_value_definitions:
|
166
|
-
enum_value_definition {
|
167
|
-
| enum_value_definitions enum_value_definition {
|
166
|
+
enum_value_definition { result = [val[0]] }
|
167
|
+
| enum_value_definitions enum_value_definition { result = val[0] << val[1] }
|
168
168
|
|
169
169
|
arguments_opt:
|
170
|
-
/* none */ {
|
171
|
-
| LPAREN arguments_list RPAREN {
|
170
|
+
/* none */ { result = EMPTY_ARRAY }
|
171
|
+
| LPAREN arguments_list RPAREN { result = val[1] }
|
172
172
|
|
173
173
|
arguments_list:
|
174
|
-
argument {
|
174
|
+
argument { result = [val[0]] }
|
175
175
|
| arguments_list argument { val[0] << val[1] }
|
176
176
|
|
177
177
|
argument:
|
178
|
-
name COLON input_value {
|
178
|
+
name COLON input_value { result = make_node(:Argument, name: val[0], value: val[2], position_source: val[0])}
|
179
179
|
|
180
180
|
literal_value:
|
181
|
-
FLOAT {
|
182
|
-
| INT {
|
183
|
-
| STRING {
|
184
|
-
| TRUE {
|
185
|
-
| FALSE {
|
181
|
+
FLOAT { result = val[0].to_f }
|
182
|
+
| INT { result = val[0].to_i }
|
183
|
+
| STRING { result = val[0].to_s }
|
184
|
+
| TRUE { result = true }
|
185
|
+
| FALSE { result = false }
|
186
186
|
| null_value
|
187
187
|
| enum_value
|
188
188
|
| list_value
|
@@ -193,58 +193,58 @@ rule
|
|
193
193
|
| variable
|
194
194
|
| object_value
|
195
195
|
|
196
|
-
null_value: NULL {
|
197
|
-
variable: VAR_SIGN name {
|
196
|
+
null_value: NULL { result = make_node(:NullValue, name: val[0], position_source: val[0]) }
|
197
|
+
variable: VAR_SIGN name { result = make_node(:VariableIdentifier, name: val[1], position_source: val[0]) }
|
198
198
|
|
199
199
|
list_value:
|
200
|
-
LBRACKET RBRACKET {
|
201
|
-
| LBRACKET list_value_list RBRACKET {
|
200
|
+
LBRACKET RBRACKET { result = EMPTY_ARRAY }
|
201
|
+
| LBRACKET list_value_list RBRACKET { result = val[1] }
|
202
202
|
|
203
203
|
list_value_list:
|
204
|
-
input_value {
|
204
|
+
input_value { result = [val[0]] }
|
205
205
|
| list_value_list input_value { val[0] << val[1] }
|
206
206
|
|
207
207
|
object_value:
|
208
|
-
LCURLY RCURLY {
|
209
|
-
| LCURLY object_value_list RCURLY {
|
208
|
+
LCURLY RCURLY { result = make_node(:InputObject, arguments: [], position_source: val[0])}
|
209
|
+
| LCURLY object_value_list RCURLY { result = make_node(:InputObject, arguments: val[1], position_source: val[0])}
|
210
210
|
|
211
211
|
object_value_list:
|
212
|
-
object_value_field {
|
212
|
+
object_value_field { result = [val[0]] }
|
213
213
|
| object_value_list object_value_field { val[0] << val[1] }
|
214
214
|
|
215
215
|
object_value_field:
|
216
|
-
name COLON input_value {
|
216
|
+
name COLON input_value { result = make_node(:Argument, name: val[0], value: val[2], position_source: val[0])}
|
217
217
|
|
218
218
|
/* like the previous, but with literals only: */
|
219
219
|
object_literal_value:
|
220
|
-
LCURLY RCURLY {
|
221
|
-
| LCURLY object_literal_value_list RCURLY {
|
220
|
+
LCURLY RCURLY { result = make_node(:InputObject, arguments: [], position_source: val[0])}
|
221
|
+
| LCURLY object_literal_value_list RCURLY { result = make_node(:InputObject, arguments: val[1], position_source: val[0])}
|
222
222
|
|
223
223
|
object_literal_value_list:
|
224
|
-
object_literal_value_field {
|
224
|
+
object_literal_value_field { result = [val[0]] }
|
225
225
|
| object_literal_value_list object_literal_value_field { val[0] << val[1] }
|
226
226
|
|
227
227
|
object_literal_value_field:
|
228
|
-
name COLON literal_value {
|
228
|
+
name COLON literal_value { result = make_node(:Argument, name: val[0], value: val[2], position_source: val[0])}
|
229
229
|
|
230
|
-
enum_value: enum_name {
|
230
|
+
enum_value: enum_name { result = make_node(:Enum, name: val[0], position_source: val[0]) }
|
231
231
|
|
232
232
|
directives_list_opt:
|
233
|
-
/* none */ {
|
233
|
+
/* none */ { result = EMPTY_ARRAY }
|
234
234
|
| directives_list
|
235
235
|
|
236
236
|
directives_list:
|
237
|
-
directive {
|
237
|
+
directive { result = [val[0]] }
|
238
238
|
| directives_list directive { val[0] << val[1] }
|
239
239
|
|
240
|
-
directive: DIR_SIGN name arguments_opt {
|
240
|
+
directive: DIR_SIGN name arguments_opt { result = make_node(:Directive, name: val[1], arguments: val[2], position_source: val[0]) }
|
241
241
|
|
242
242
|
fragment_spread:
|
243
|
-
ELLIPSIS name_without_on directives_list_opt {
|
243
|
+
ELLIPSIS name_without_on directives_list_opt { result = make_node(:FragmentSpread, name: val[1], directives: val[2], position_source: val[0]) }
|
244
244
|
|
245
245
|
inline_fragment:
|
246
246
|
ELLIPSIS ON type directives_list_opt selection_set {
|
247
|
-
|
247
|
+
result = make_node(:InlineFragment, {
|
248
248
|
type: val[2],
|
249
249
|
directives: val[3],
|
250
250
|
selections: val[4],
|
@@ -252,7 +252,7 @@ rule
|
|
252
252
|
})
|
253
253
|
}
|
254
254
|
| ELLIPSIS directives_list_opt selection_set {
|
255
|
-
|
255
|
+
result = make_node(:InlineFragment, {
|
256
256
|
type: nil,
|
257
257
|
directives: val[1],
|
258
258
|
selections: val[2],
|
@@ -262,7 +262,7 @@ rule
|
|
262
262
|
|
263
263
|
fragment_definition:
|
264
264
|
FRAGMENT fragment_name_opt ON type directives_list_opt selection_set {
|
265
|
-
|
265
|
+
result = make_node(:FragmentDefinition, {
|
266
266
|
name: val[1],
|
267
267
|
type: val[3],
|
268
268
|
directives: val[4],
|
@@ -273,7 +273,7 @@ rule
|
|
273
273
|
}
|
274
274
|
|
275
275
|
fragment_name_opt:
|
276
|
-
/* none */ {
|
276
|
+
/* none */ { result = nil }
|
277
277
|
| name_without_on
|
278
278
|
|
279
279
|
type_system_definition:
|
@@ -282,14 +282,14 @@ rule
|
|
282
282
|
| directive_definition
|
283
283
|
|
284
284
|
schema_definition:
|
285
|
-
SCHEMA directives_list_opt LCURLY operation_type_definition_list RCURLY {
|
285
|
+
SCHEMA directives_list_opt LCURLY operation_type_definition_list RCURLY { result = make_node(:SchemaDefinition, position_source: val[0], definition_line: val[0].line, directives: val[1], **val[3]) }
|
286
286
|
|
287
287
|
operation_type_definition_list:
|
288
288
|
operation_type_definition
|
289
|
-
| operation_type_definition_list operation_type_definition {
|
289
|
+
| operation_type_definition_list operation_type_definition { result = val[0].merge(val[1]) }
|
290
290
|
|
291
291
|
operation_type_definition:
|
292
|
-
operation_type COLON name {
|
292
|
+
operation_type COLON name { result = { val[0].to_s.to_sym => val[2] } }
|
293
293
|
|
294
294
|
type_definition:
|
295
295
|
scalar_type_definition
|
@@ -304,8 +304,8 @@ rule
|
|
304
304
|
| type_extension
|
305
305
|
|
306
306
|
schema_extension:
|
307
|
-
EXTEND SCHEMA directives_list_opt LCURLY operation_type_definition_list RCURLY {
|
308
|
-
| EXTEND SCHEMA directives_list {
|
307
|
+
EXTEND SCHEMA directives_list_opt LCURLY operation_type_definition_list RCURLY { result = make_node(:SchemaExtension, position_source: val[0], directives: val[2], **val[4]) }
|
308
|
+
| EXTEND SCHEMA directives_list { result = make_node(:SchemaExtension, position_source: val[0], directives: val[2]) }
|
309
309
|
|
310
310
|
type_extension:
|
311
311
|
scalar_type_extension
|
@@ -315,30 +315,30 @@ rule
|
|
315
315
|
| enum_type_extension
|
316
316
|
| input_object_type_extension
|
317
317
|
|
318
|
-
scalar_type_extension: EXTEND SCALAR name directives_list {
|
318
|
+
scalar_type_extension: EXTEND SCALAR name directives_list { result = make_node(:ScalarTypeExtension, name: val[2], directives: val[3], position_source: val[0]) }
|
319
319
|
|
320
320
|
object_type_extension:
|
321
321
|
/* TODO - This first one shouldn't be necessary but parser is getting confused */
|
322
|
-
EXTEND TYPE name implements LCURLY field_definition_list RCURLY {
|
323
|
-
| EXTEND TYPE name implements_opt directives_list_opt LCURLY field_definition_list RCURLY {
|
324
|
-
| EXTEND TYPE name implements_opt directives_list {
|
325
|
-
| EXTEND TYPE name implements {
|
322
|
+
EXTEND TYPE name implements LCURLY field_definition_list RCURLY { result = make_node(:ObjectTypeExtension, name: val[2], interfaces: val[3], directives: [], fields: val[5], position_source: val[0]) }
|
323
|
+
| EXTEND TYPE name implements_opt directives_list_opt LCURLY field_definition_list RCURLY { result = make_node(:ObjectTypeExtension, name: val[2], interfaces: val[3], directives: val[4], fields: val[6], position_source: val[0]) }
|
324
|
+
| EXTEND TYPE name implements_opt directives_list { result = make_node(:ObjectTypeExtension, name: val[2], interfaces: val[3], directives: val[4], fields: [], position_source: val[0]) }
|
325
|
+
| EXTEND TYPE name implements { result = make_node(:ObjectTypeExtension, name: val[2], interfaces: val[3], directives: [], fields: [], position_source: val[0]) }
|
326
326
|
|
327
327
|
interface_type_extension:
|
328
|
-
EXTEND INTERFACE name directives_list_opt LCURLY field_definition_list RCURLY {
|
329
|
-
| EXTEND INTERFACE name directives_list {
|
328
|
+
EXTEND INTERFACE name directives_list_opt LCURLY field_definition_list RCURLY { result = make_node(:InterfaceTypeExtension, name: val[2], directives: val[3], fields: val[5], position_source: val[0]) }
|
329
|
+
| EXTEND INTERFACE name directives_list { result = make_node(:InterfaceTypeExtension, name: val[2], directives: val[3], fields: [], position_source: val[0]) }
|
330
330
|
|
331
331
|
union_type_extension:
|
332
|
-
EXTEND UNION name directives_list_opt EQUALS union_members {
|
333
|
-
| EXTEND UNION name directives_list {
|
332
|
+
EXTEND UNION name directives_list_opt EQUALS union_members { result = make_node(:UnionTypeExtension, name: val[2], directives: val[3], types: val[5], position_source: val[0]) }
|
333
|
+
| EXTEND UNION name directives_list { result = make_node(:UnionTypeExtension, name: val[2], directives: val[3], types: [], position_source: val[0]) }
|
334
334
|
|
335
335
|
enum_type_extension:
|
336
|
-
EXTEND ENUM name directives_list_opt LCURLY enum_value_definitions RCURLY {
|
337
|
-
| EXTEND ENUM name directives_list {
|
336
|
+
EXTEND ENUM name directives_list_opt LCURLY enum_value_definitions RCURLY { result = make_node(:EnumTypeExtension, name: val[2], directives: val[3], values: val[5], position_source: val[0]) }
|
337
|
+
| EXTEND ENUM name directives_list { result = make_node(:EnumTypeExtension, name: val[2], directives: val[3], values: [], position_source: val[0]) }
|
338
338
|
|
339
339
|
input_object_type_extension:
|
340
|
-
EXTEND INPUT name directives_list_opt LCURLY input_value_definition_list RCURLY {
|
341
|
-
| EXTEND INPUT name directives_list {
|
340
|
+
EXTEND INPUT name directives_list_opt LCURLY input_value_definition_list RCURLY { result = make_node(:InputObjectTypeExtension, name: val[2], directives: val[3], fields: val[5], position_source: val[0]) }
|
341
|
+
| EXTEND INPUT name directives_list { result = make_node(:InputObjectTypeExtension, name: val[2], directives: val[3], fields: [], position_source: val[0]) }
|
342
342
|
|
343
343
|
description: STRING
|
344
344
|
|
@@ -348,85 +348,85 @@ rule
|
|
348
348
|
|
349
349
|
scalar_type_definition:
|
350
350
|
description_opt SCALAR name directives_list_opt {
|
351
|
-
|
351
|
+
result = make_node(:ScalarTypeDefinition, name: val[2], directives: val[3], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
352
352
|
}
|
353
353
|
|
354
354
|
object_type_definition:
|
355
355
|
description_opt TYPE name implements_opt directives_list_opt LCURLY field_definition_list RCURLY {
|
356
|
-
|
356
|
+
result = make_node(:ObjectTypeDefinition, name: val[2], interfaces: val[3], directives: val[4], fields: val[6], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
357
357
|
}
|
358
358
|
|
359
359
|
implements_opt:
|
360
|
-
/* none */ {
|
360
|
+
/* none */ { result = EMPTY_ARRAY }
|
361
361
|
| implements
|
362
362
|
|
363
363
|
implements:
|
364
|
-
IMPLEMENTS AMP interfaces_list {
|
365
|
-
| IMPLEMENTS interfaces_list {
|
366
|
-
| IMPLEMENTS legacy_interfaces_list {
|
364
|
+
IMPLEMENTS AMP interfaces_list { result = val[2] }
|
365
|
+
| IMPLEMENTS interfaces_list { result = val[1] }
|
366
|
+
| IMPLEMENTS legacy_interfaces_list { result = val[1] }
|
367
367
|
|
368
368
|
interfaces_list:
|
369
|
-
name {
|
369
|
+
name { result = [make_node(:TypeName, name: val[0], position_source: val[0])] }
|
370
370
|
| interfaces_list AMP name { val[0] << make_node(:TypeName, name: val[2], position_source: val[2]) }
|
371
371
|
|
372
372
|
legacy_interfaces_list:
|
373
|
-
name {
|
373
|
+
name { result = [make_node(:TypeName, name: val[0], position_source: val[0])] }
|
374
374
|
| legacy_interfaces_list name { val[0] << make_node(:TypeName, name: val[1], position_source: val[1]) }
|
375
375
|
|
376
376
|
input_value_definition:
|
377
377
|
description_opt name COLON type default_value_opt directives_list_opt {
|
378
|
-
|
378
|
+
result = make_node(:InputValueDefinition, name: val[1], type: val[3], default_value: val[4], directives: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
379
379
|
}
|
380
380
|
|
381
381
|
input_value_definition_list:
|
382
|
-
input_value_definition {
|
382
|
+
input_value_definition { result = [val[0]] }
|
383
383
|
| input_value_definition_list input_value_definition { val[0] << val[1] }
|
384
384
|
|
385
385
|
arguments_definitions_opt:
|
386
|
-
/* none */ {
|
387
|
-
| LPAREN input_value_definition_list RPAREN {
|
386
|
+
/* none */ { result = EMPTY_ARRAY }
|
387
|
+
| LPAREN input_value_definition_list RPAREN { result = val[1] }
|
388
388
|
|
389
389
|
field_definition:
|
390
390
|
description_opt name arguments_definitions_opt COLON type directives_list_opt {
|
391
|
-
|
391
|
+
result = make_node(:FieldDefinition, name: val[1], arguments: val[2], type: val[4], directives: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
392
392
|
}
|
393
393
|
|
394
394
|
field_definition_list:
|
395
|
-
/* none */ {
|
396
|
-
| field_definition {
|
395
|
+
/* none */ { result = EMPTY_ARRAY }
|
396
|
+
| field_definition { result = [val[0]] }
|
397
397
|
| field_definition_list field_definition { val[0] << val[1] }
|
398
398
|
|
399
399
|
interface_type_definition:
|
400
400
|
description_opt INTERFACE name directives_list_opt LCURLY field_definition_list RCURLY {
|
401
|
-
|
401
|
+
result = make_node(:InterfaceTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
402
402
|
}
|
403
403
|
|
404
404
|
union_members:
|
405
|
-
name {
|
405
|
+
name { result = [make_node(:TypeName, name: val[0], position_source: val[0])]}
|
406
406
|
| union_members PIPE name { val[0] << make_node(:TypeName, name: val[2], position_source: val[2]) }
|
407
407
|
|
408
408
|
union_type_definition:
|
409
409
|
description_opt UNION name directives_list_opt EQUALS union_members {
|
410
|
-
|
410
|
+
result = make_node(:UnionTypeDefinition, name: val[2], directives: val[3], types: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
411
411
|
}
|
412
412
|
|
413
413
|
enum_type_definition:
|
414
414
|
description_opt ENUM name directives_list_opt LCURLY enum_value_definitions RCURLY {
|
415
|
-
|
415
|
+
result = make_node(:EnumTypeDefinition, name: val[2], directives: val[3], values: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
416
416
|
}
|
417
417
|
|
418
418
|
input_object_type_definition:
|
419
419
|
description_opt INPUT name directives_list_opt LCURLY input_value_definition_list RCURLY {
|
420
|
-
|
420
|
+
result = make_node(:InputObjectTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
421
421
|
}
|
422
422
|
|
423
423
|
directive_definition:
|
424
424
|
description_opt DIRECTIVE DIR_SIGN name arguments_definitions_opt ON directive_locations {
|
425
|
-
|
425
|
+
result = make_node(:DirectiveDefinition, name: val[3], arguments: val[4], locations: val[6], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
426
426
|
}
|
427
427
|
|
428
428
|
directive_locations:
|
429
|
-
name {
|
429
|
+
name { result = [make_node(:DirectiveLocation, name: val[0].to_s, position_source: val[0])] }
|
430
430
|
| directive_locations PIPE name { val[0] << make_node(:DirectiveLocation, name: val[2].to_s, position_source: val[2]) }
|
431
431
|
end
|
432
432
|
|
@@ -30,16 +30,17 @@ module GraphQL
|
|
30
30
|
|
31
31
|
def self.use(schema_defn)
|
32
32
|
if schema_defn.is_a?(Class)
|
33
|
-
schema_defn.connections = self.new
|
33
|
+
schema_defn.connections = self.new(schema: schema_defn)
|
34
34
|
else
|
35
35
|
# Unwrap a `.define` object
|
36
36
|
schema_defn = schema_defn.target
|
37
|
-
schema_defn.connections = self.new
|
37
|
+
schema_defn.connections = self.new(schema: schema_defn)
|
38
38
|
schema_defn.class.connections = schema_defn.connections
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def initialize
|
42
|
+
def initialize(schema:)
|
43
|
+
@schema = schema
|
43
44
|
@wrappers = {}
|
44
45
|
add_default
|
45
46
|
end
|
@@ -52,12 +53,23 @@ module GraphQL
|
|
52
53
|
@wrappers.delete(nodes_class)
|
53
54
|
end
|
54
55
|
|
56
|
+
def all_wrappers
|
57
|
+
all_wrappers = {}
|
58
|
+
@schema.ancestors.reverse_each do |schema_class|
|
59
|
+
if schema_class.respond_to?(:connections) && (c = schema_class.connections)
|
60
|
+
all_wrappers.merge!(c.wrappers)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
all_wrappers
|
64
|
+
end
|
65
|
+
|
55
66
|
# Used by the runtime to wrap values in connection wrappers.
|
56
67
|
# @api Private
|
57
|
-
def wrap(field, object, arguments, context)
|
68
|
+
def wrap(field, object, arguments, context, wrappers: all_wrappers)
|
58
69
|
impl = nil
|
70
|
+
|
59
71
|
object.class.ancestors.each { |cls|
|
60
|
-
impl =
|
72
|
+
impl = wrappers[cls]
|
61
73
|
break if impl
|
62
74
|
}
|
63
75
|
|
@@ -76,6 +88,10 @@ module GraphQL
|
|
76
88
|
)
|
77
89
|
end
|
78
90
|
|
91
|
+
protected
|
92
|
+
|
93
|
+
attr_reader :wrappers
|
94
|
+
|
79
95
|
private
|
80
96
|
|
81
97
|
def add_default
|