graphql 1.8.0.pre9 → 1.8.0.pre10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/argument.rb +1 -0
  3. data/lib/graphql/base_type.rb +2 -0
  4. data/lib/graphql/compatibility/query_parser_specification.rb +110 -0
  5. data/lib/graphql/deprecated_dsl.rb +15 -3
  6. data/lib/graphql/directive.rb +1 -0
  7. data/lib/graphql/enum_type.rb +2 -0
  8. data/lib/graphql/execution/multiplex.rb +1 -1
  9. data/lib/graphql/field.rb +2 -0
  10. data/lib/graphql/introspection/entry_points.rb +2 -2
  11. data/lib/graphql/introspection/schema_field.rb +1 -1
  12. data/lib/graphql/introspection/type_by_name_field.rb +1 -1
  13. data/lib/graphql/language/parser.rb +25 -25
  14. data/lib/graphql/language/parser.y +7 -7
  15. data/lib/graphql/query/arguments.rb +12 -0
  16. data/lib/graphql/relay/mutation/instrumentation.rb +1 -1
  17. data/lib/graphql/relay/mutation/resolve.rb +5 -1
  18. data/lib/graphql/schema.rb +5 -1
  19. data/lib/graphql/schema/argument.rb +1 -0
  20. data/lib/graphql/schema/build_from_definition.rb +60 -18
  21. data/lib/graphql/schema/enum.rb +1 -0
  22. data/lib/graphql/schema/enum_value.rb +1 -0
  23. data/lib/graphql/schema/field.rb +44 -31
  24. data/lib/graphql/schema/field/dynamic_resolve.rb +4 -8
  25. data/lib/graphql/schema/input_object.rb +30 -19
  26. data/lib/graphql/schema/interface.rb +12 -5
  27. data/lib/graphql/schema/member.rb +10 -0
  28. data/lib/graphql/schema/member/build_type.rb +3 -1
  29. data/lib/graphql/schema/member/has_arguments.rb +50 -0
  30. data/lib/graphql/schema/member/has_fields.rb +1 -1
  31. data/lib/graphql/schema/member/instrumentation.rb +4 -4
  32. data/lib/graphql/schema/mutation.rb +195 -0
  33. data/lib/graphql/schema/object.rb +4 -5
  34. data/lib/graphql/schema/relay_classic_mutation.rb +85 -0
  35. data/lib/graphql/schema/scalar.rb +1 -0
  36. data/lib/graphql/schema/traversal.rb +1 -1
  37. data/lib/graphql/schema/union.rb +1 -0
  38. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +1 -1
  39. data/lib/graphql/unresolved_type_error.rb +3 -2
  40. data/lib/graphql/upgrader/member.rb +194 -19
  41. data/lib/graphql/version.rb +1 -1
  42. data/spec/fixtures/upgrader/delete_project.original.rb +28 -0
  43. data/spec/fixtures/upgrader/delete_project.transformed.rb +27 -0
  44. data/spec/fixtures/upgrader/increment_count.original.rb +59 -0
  45. data/spec/fixtures/upgrader/increment_count.transformed.rb +50 -0
  46. data/spec/graphql/execution/multiplex_spec.rb +1 -1
  47. data/spec/graphql/language/parser_spec.rb +0 -74
  48. data/spec/graphql/query/serial_execution/value_resolution_spec.rb +2 -8
  49. data/spec/graphql/query_spec.rb +26 -0
  50. data/spec/graphql/relay/mutation_spec.rb +2 -2
  51. data/spec/graphql/schema/build_from_definition_spec.rb +59 -0
  52. data/spec/graphql/schema/field_spec.rb +24 -0
  53. data/spec/graphql/schema/input_object_spec.rb +1 -0
  54. data/spec/graphql/schema/interface_spec.rb +4 -1
  55. data/spec/graphql/schema/mutation_spec.rb +99 -0
  56. data/spec/graphql/schema/relay_classic_mutation_spec.rb +28 -0
  57. data/spec/support/jazz.rb +25 -1
  58. data/spec/support/star_wars/schema.rb +17 -27
  59. metadata +17 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2451d4a7af012ddb1bcf72ea1bd4eeb6526fbf5bd0ca64dc166c2fbb06f4eed3
4
- data.tar.gz: c0b094732484e5bc79bf988afe4c72292aad624683378cef4148f5fa93897d01
3
+ metadata.gz: 4fbdf256acbc1259fd520d07b4368c587954b9068bdfca85ab9a998057cbfa46
4
+ data.tar.gz: c78d32fa1e602301a7e370b68bc881b6f4a794355742a45608d6b5c5485d2d90
5
5
  SHA512:
6
- metadata.gz: 027065ef7bb22b902d5fdfbeabe2c658b38d740b2229477dbee2eb370691e0004c0daf30f44a3cfb05e2b0e81597bc7073b93967959ff5aea62173713518a6b8
7
- data.tar.gz: 5c87daac7d2420c90a480135e684197be3fceec67f6ac0288e41a8ec11efb53c8103ef81e110d1c7c1a1512b14bd093ce9d61089105f1e9b9fa0f1dcedceffa9
6
+ metadata.gz: 014b2608ee027d52e6145648f5eaf894dee93796a75bd01b13c2c4d0f72bd04ea806f7f7e67bb91a5d5b9d2d9e03eecdd77a9e5ba0b9bed4affb5df9e4881398
7
+ data.tar.gz: fe1727eca3bb06acff963916a78795980295c1c5b61a040a191d7d61d26363aa1c93cf58774673bf97c051ff614d9ba6ea84ee6e632b2b2d70ae3ecc6809b2e8
@@ -37,6 +37,7 @@ module GraphQL
37
37
  include GraphQL::Define::InstanceDefinable
38
38
  accepts_definitions :name, :type, :description, :default_value, :as, :prepare
39
39
  attr_accessor :type, :description, :default_value, :name, :as
40
+ attr_accessor :ast_node
40
41
 
41
42
  ensure_defined(:name, :description, :default_value, :type=, :type, :as, :expose_as, :prepare)
42
43
 
@@ -19,6 +19,8 @@ module GraphQL
19
19
 
20
20
  ensure_defined(:graphql_name, :name, :description, :introspection?, :default_scalar?)
21
21
 
22
+ attr_accessor :ast_node
23
+
22
24
  def initialize
23
25
  @introspection = false
24
26
  @default_scalar = false
@@ -123,6 +123,116 @@ module GraphQL
123
123
  end
124
124
  assert_equal [1,26], [err_2.line, err_2.col]
125
125
  end
126
+
127
+ def test_enum_value_definitions_have_a_position
128
+ document = parse("""
129
+ enum Enum {
130
+ VALUE
131
+ }
132
+ """)
133
+
134
+ assert_equal [3, 17], document.definitions[0].values[0].position
135
+ end
136
+
137
+ def test_field_definitions_have_a_position
138
+ document = parse("""
139
+ type A {
140
+ field: String
141
+ }
142
+ """)
143
+
144
+ assert_equal [3, 17], document.definitions[0].fields[0].position
145
+ end
146
+
147
+ def test_input_value_definitions_have_a_position
148
+ document = parse("""
149
+ input A {
150
+ field: String
151
+ }
152
+ """)
153
+
154
+ assert_equal [3, 17], document.definitions[0].fields[0].position
155
+ end
156
+
157
+ def test_parses_when_there_are_no_interfaces
158
+ schema = "
159
+ type A {
160
+ a: String
161
+ }
162
+ "
163
+
164
+ document = parse(schema)
165
+
166
+ assert_equal [], document.definitions[0].interfaces.map(&:name)
167
+ end
168
+
169
+ def test_parses_implements_with_leading_ampersand
170
+ schema = "
171
+ type A implements & B {
172
+ a: String
173
+ }
174
+ "
175
+
176
+ document = parse(schema)
177
+
178
+ assert_equal ["B"], document.definitions[0].interfaces.map(&:name)
179
+ assert_equal [2, 35], document.definitions[0].interfaces[0].position
180
+ end
181
+
182
+ def test_parses_implements_with_leading_ampersand_and_multiple_interfaces
183
+ schema = "
184
+ type A implements & B & C {
185
+ a: String
186
+ }
187
+ "
188
+
189
+ document = parse(schema)
190
+
191
+ assert_equal ["B", "C"], document.definitions[0].interfaces.map(&:name)
192
+ assert_equal [2, 35], document.definitions[0].interfaces[0].position
193
+ assert_equal [2, 39], document.definitions[0].interfaces[1].position
194
+ end
195
+
196
+ def test_parses_implements_without_leading_ampersand
197
+ schema = "
198
+ type A implements B {
199
+ a: String
200
+ }
201
+ "
202
+
203
+ document = parse(schema)
204
+
205
+ assert_equal ["B"], document.definitions[0].interfaces.map(&:name)
206
+ assert_equal [2, 33], document.definitions[0].interfaces[0].position
207
+ end
208
+
209
+ def test_parses_implements_without_leading_ampersand_and_multiple_interfaces
210
+ schema = "
211
+ type A implements B & C {
212
+ a: String
213
+ }
214
+ "
215
+
216
+ document = parse(schema)
217
+
218
+ assert_equal ["B", "C"], document.definitions[0].interfaces.map(&:name)
219
+ assert_equal [2, 33], document.definitions[0].interfaces[0].position
220
+ assert_equal [2, 37], document.definitions[0].interfaces[1].position
221
+ end
222
+
223
+ def test_supports_old_syntax_for_parsing_multiple_interfaces
224
+ schema = "
225
+ type A implements B, C {
226
+ a: String
227
+ }
228
+ "
229
+
230
+ document = parse(schema)
231
+
232
+ assert_equal ["B", "C"], document.definitions[0].interfaces.map(&:name)
233
+ assert_equal [2, 33], document.definitions[0].interfaces[0].position
234
+ assert_equal [2, 36], document.definitions[0].interfaces[1].position
235
+ end
126
236
  end
127
237
  end
128
238
 
@@ -13,8 +13,17 @@ module GraphQL
13
13
  # GraphQL::DeprecatedDSL.activate
14
14
  #
15
15
  module DeprecatedDSL
16
+ TYPE_CLASSES = [
17
+ GraphQL::Schema::Scalar,
18
+ GraphQL::Schema::Enum,
19
+ GraphQL::Schema::InputObject,
20
+ GraphQL::Schema::Union,
21
+ GraphQL::Schema::Interface,
22
+ GraphQL::Schema::Object,
23
+ ]
24
+
16
25
  def self.activate
17
- GraphQL::Schema::Member.extend(Methods)
26
+ TYPE_CLASSES.each { |c| c.extend(Methods) }
18
27
  GraphQL::Schema::Member::ListTypeProxy.include(Methods)
19
28
  GraphQL::Schema::Member::NonNullTypeProxy.include(Methods)
20
29
  end
@@ -23,8 +32,11 @@ module GraphQL
23
32
  to_non_null_type
24
33
  end
25
34
  end
26
- refine GraphQL::Schema::Member.singleton_class do
27
- include Methods
35
+
36
+ TYPE_CLASSES.each do |type_class|
37
+ refine type_class.singleton_class do
38
+ include Methods
39
+ end
28
40
  end
29
41
  end
30
42
  end
@@ -11,6 +11,7 @@ module GraphQL
11
11
  accepts_definitions :locations, :name, :description, :arguments, :default_directive, argument: GraphQL::Define::AssignArgument
12
12
 
13
13
  attr_accessor :locations, :arguments, :name, :description, :arguments_class
14
+ attr_accessor :ast_node
14
15
  # @api private
15
16
  attr_writer :default_directive
16
17
  ensure_defined(:locations, :arguments, :name, :description, :default_directive?)
@@ -74,6 +74,7 @@ module GraphQL
74
74
  class EnumType < GraphQL::BaseType
75
75
  accepts_definitions :values, value: GraphQL::Define::AssignEnumValue
76
76
  ensure_defined(:values, :validate_non_null_input, :coerce_non_null_input, :coerce_result)
77
+ attr_accessor :ast_node
77
78
 
78
79
  def initialize
79
80
  super
@@ -137,6 +138,7 @@ module GraphQL
137
138
  ATTRIBUTES = [:name, :description, :deprecation_reason, :value]
138
139
  accepts_definitions(*ATTRIBUTES)
139
140
  attr_accessor(*ATTRIBUTES)
141
+ attr_accessor :ast_node
140
142
  ensure_defined(*ATTRIBUTES)
141
143
 
142
144
  def name=(new_name)
@@ -93,7 +93,7 @@ module GraphQL
93
93
  end
94
94
  rescue StandardError
95
95
  # Assign values here so that the query's `@executed` becomes true
96
- queries.map { |q| q.result_values ||= nil }
96
+ queries.map { |q| q.result_values ||= {} }
97
97
  raise
98
98
  end
99
99
 
data/lib/graphql/field.rb CHANGED
@@ -193,6 +193,8 @@ module GraphQL
193
193
  # @return [Boolean] True if this field should be traced. By default, fields are only traced if they are not a ScalarType or EnumType.
194
194
  attr_accessor :trace
195
195
 
196
+ attr_accessor :ast_node
197
+
196
198
  # @return [Boolean]
197
199
  def connection?
198
200
  @connection
@@ -11,7 +11,7 @@ module GraphQL
11
11
  # Apply wrapping manually since this field isn't wrapped by instrumentation
12
12
  schema = @context.query.schema
13
13
  schema_type = schema.introspection_system.schema_type
14
- schema_type.metadata[:object_class].new(schema, @context)
14
+ schema_type.metadata[:type_class].new(schema, @context)
15
15
  end
16
16
 
17
17
  def __type(name:)
@@ -19,7 +19,7 @@ module GraphQL
19
19
  if type
20
20
  # Apply wrapping manually since this field isn't wrapped by instrumentation
21
21
  type_type = @context.schema.introspection_system.type_type
22
- type_type.metadata[:object_class].new(type, @context)
22
+ type_type.metadata[:type_class].new(type, @context)
23
23
  else
24
24
  nil
25
25
  end
@@ -9,7 +9,7 @@ module GraphQL
9
9
  # Apply wrapping manually since this field isn't wrapped by instrumentation
10
10
  schema = ctx.query.schema
11
11
  schema_type = schema.introspection_system.schema_type
12
- schema_type.metadata[:object_class].new(schema, ctx.query.context)
12
+ schema_type.metadata[:type_class].new(schema, ctx.query.context)
13
13
  }
14
14
  end
15
15
  end
@@ -12,7 +12,7 @@ module GraphQL
12
12
  if type
13
13
  # Apply wrapping manually since this field isn't wrapped by instrumentation
14
14
  type_type = ctx.schema.introspection_system.type_type
15
- type_type.metadata[:object_class].new(type, ctx)
15
+ type_type.metadata[:type_class].new(type, ctx)
16
16
  else
17
17
  nil
18
18
  end
@@ -104,15 +104,15 @@ end
104
104
  ##### State transition tables begin ###
105
105
 
106
106
  racc_action_table = [
107
- -127, 10, 11, 12, 140, 80, 77, 226, 140, 76,
108
- 130, 99, 36, 37, 38, 39, 40, 41, 42, 43,
107
+ -127, 10, 11, 12, 115, 10, 11, 12, 140, 10,
108
+ 11, 12, 36, 37, 38, 39, 40, 41, 42, 43,
109
109
  44, 45, 46, 47, 48, 49, 73, 10, 11, 12,
110
110
  80, -127, 119, -127, 140, 140, 140, 190, 36, 37,
111
111
  38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
112
- 48, 49, 53, 10, 11, 12, 80, 59, 80, 115,
113
- 10, 11, 12, 31, 36, 37, 38, 39, 40, 41,
112
+ 48, 49, 53, 10, 11, 12, 80, 59, 80, 140,
113
+ 77, 80, 226, 76, 36, 37, 38, 39, 40, 41,
114
114
  42, 43, 44, 45, 46, 47, 48, 49, 191, 10,
115
- 11, 12, 140, 59, 62, 226, 10, 11, 12, 69,
115
+ 11, 12, 140, 59, 31, 226, 130, 99, 62, 69,
116
116
  36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
117
117
  46, 47, 48, 49, 240, 70, 10, 11, 12, 59,
118
118
  72, 84, 80, 90, 186, 80, 80, 158, 37, 38,
@@ -256,15 +256,15 @@ racc_action_table = [
256
256
  38, 39, 40, 41, 42, 43, 44, 45, 156, 157 ]
257
257
 
258
258
  racc_action_check = [
259
- 122, 90, 90, 90, 223, 135, 58, 223, 236, 58,
260
- 97, 97, 90, 90, 90, 90, 90, 90, 90, 90,
259
+ 122, 90, 90, 90, 85, 85, 85, 85, 236, 62,
260
+ 62, 62, 90, 90, 90, 90, 90, 90, 90, 90,
261
261
  90, 90, 90, 90, 90, 90, 52, 52, 52, 52,
262
262
  236, 122, 90, 122, 114, 142, 110, 142, 52, 52,
263
263
  52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
264
- 52, 52, 9, 9, 9, 9, 114, 52, 110, 85,
265
- 85, 85, 85, 1, 9, 9, 9, 9, 9, 9,
264
+ 52, 52, 9, 9, 9, 9, 114, 52, 110, 223,
265
+ 58, 135, 223, 58, 9, 9, 9, 9, 9, 9,
266
266
  9, 9, 9, 9, 9, 9, 9, 9, 143, 143,
267
- 143, 143, 208, 9, 17, 208, 62, 62, 62, 30,
267
+ 143, 143, 208, 9, 1, 208, 97, 97, 17, 30,
268
268
  143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
269
269
  143, 143, 143, 143, 226, 31, 226, 226, 226, 143,
270
270
  33, 60, 63, 64, 226, 65, 66, 226, 226, 226,
@@ -408,20 +408,20 @@ racc_action_check = [
408
408
  125, 125, 125, 125, 125, 125, 125, 125, 125, 125 ]
409
409
 
410
410
  racc_action_pointer = [
411
- 626, 63, nil, 751, nil, nil, nil, nil, 549, 49,
412
- nil, nil, nil, 1149, nil, nil, nil, 82, nil, nil,
411
+ 626, 84, nil, 751, nil, nil, nil, nil, 549, 49,
412
+ nil, nil, nil, 1149, nil, nil, nil, 86, nil, nil,
413
413
  nil, nil, nil, nil, 874, 949, 974, 1049, 1374, 1399,
414
414
  56, 105, nil, 103, nil, nil, nil, nil, nil, nil,
415
415
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
416
- nil, nil, 23, nil, nil, nil, nil, nil, -1, 342,
417
- 96, nil, 82, 79, 94, 82, 83, 103, 107, 1074,
416
+ nil, nil, 23, nil, nil, nil, nil, nil, 53, 342,
417
+ 96, nil, 5, 79, 94, 82, 83, 103, 107, 1074,
418
418
  nil, 108, 134, nil, nil, 111, 1224, 1274, 113, nil,
419
- 599, 114, 649, 165, 724, 56, nil, 161, nil, 139,
420
- -3, 172, 161, 175, 176, 191, 200, 2, nil, 1424,
419
+ 599, 114, 649, 165, 724, 1, nil, 161, nil, 139,
420
+ -3, 172, 161, 175, 176, 191, 200, 78, nil, 1424,
421
421
  201, 198, nil, 1124, nil, 196, nil, 201, nil, nil,
422
422
  25, 1174, 224, nil, 23, nil, nil, 1199, 207, 1249,
423
423
  196, 1299, -2, 1324, 1349, 1473, 1099, 574, 217, nil,
424
- nil, nil, 223, nil, nil, -28, nil, nil, 133, nil,
424
+ nil, nil, 223, nil, nil, 28, nil, nil, 133, nil,
425
425
  nil, 232, 24, 75, 233, nil, 674, 201, nil, 699,
426
426
  nil, 230, nil, 420, nil, 202, nil, nil, nil, nil,
427
427
  nil, 221, nil, 1450, 249, nil, 524, 774, 799, 824,
@@ -430,7 +430,7 @@ racc_action_pointer = [
430
430
  nil, nil, nil, 394, nil, 251, nil, nil, 899, nil,
431
431
  nil, nil, 924, nil, nil, nil, 226, nil, 71, nil,
432
432
  nil, nil, 313, nil, nil, 368, nil, 254, 498, nil,
433
- nil, 999, nil, -7, 1024, nil, 102, nil, nil, nil,
433
+ nil, 999, nil, 48, 1024, nil, 102, nil, nil, nil,
434
434
  nil, 255, 195, nil, nil, 275, -3, 256, nil, nil,
435
435
  446, 164, nil, nil, 251, nil, nil, nil, nil ]
436
436
 
@@ -1146,7 +1146,7 @@ module_eval(<<'.,.,', 'parser.y', 112)
1146
1146
 
1147
1147
  module_eval(<<'.,.,', 'parser.y', 155)
1148
1148
  def _reduce_58(val, _values, result)
1149
- return make_node(:EnumValueDefinition, name: val[0], directives: val[1], description: get_description(val[0]))
1149
+ return make_node(:EnumValueDefinition, name: val[0], directives: val[1], description: get_description(val[0]), position_source: val[0])
1150
1150
  result
1151
1151
  end
1152
1152
  .,.,
@@ -1550,35 +1550,35 @@ module_eval(<<'.,.,', 'parser.y', 306)
1550
1550
 
1551
1551
  module_eval(<<'.,.,', 'parser.y', 309)
1552
1552
  def _reduce_127(val, _values, result)
1553
- return [make_node(:TypeName, name: val[0])]
1553
+ return [make_node(:TypeName, name: val[0], position_source: val[0])]
1554
1554
  result
1555
1555
  end
1556
1556
  .,.,
1557
1557
 
1558
1558
  module_eval(<<'.,.,', 'parser.y', 310)
1559
1559
  def _reduce_128(val, _values, result)
1560
- val[0] << make_node(:TypeName, name: val[2])
1560
+ val[0] << make_node(:TypeName, name: val[2], position_source: val[2])
1561
1561
  result
1562
1562
  end
1563
1563
  .,.,
1564
1564
 
1565
1565
  module_eval(<<'.,.,', 'parser.y', 313)
1566
1566
  def _reduce_129(val, _values, result)
1567
- return [make_node(:TypeName, name: val[0])]
1567
+ return [make_node(:TypeName, name: val[0], position_source: val[0])]
1568
1568
  result
1569
1569
  end
1570
1570
  .,.,
1571
1571
 
1572
1572
  module_eval(<<'.,.,', 'parser.y', 314)
1573
1573
  def _reduce_130(val, _values, result)
1574
- val[0] << make_node(:TypeName, name: val[1])
1574
+ val[0] << make_node(:TypeName, name: val[1], position_source: val[1])
1575
1575
  result
1576
1576
  end
1577
1577
  .,.,
1578
1578
 
1579
1579
  module_eval(<<'.,.,', 'parser.y', 318)
1580
1580
  def _reduce_131(val, _values, result)
1581
- return make_node(:InputValueDefinition, name: val[0], type: val[2], default_value: val[3], directives: val[4], description: get_description(val[0]))
1581
+ return make_node(:InputValueDefinition, name: val[0], type: val[2], default_value: val[3], directives: val[4], description: get_description(val[0]), position_source: val[0])
1582
1582
 
1583
1583
  result
1584
1584
  end
@@ -1614,7 +1614,7 @@ module_eval(<<'.,.,', 'parser.y', 327)
1614
1614
 
1615
1615
  module_eval(<<'.,.,', 'parser.y', 331)
1616
1616
  def _reduce_136(val, _values, result)
1617
- return make_node(:FieldDefinition, name: val[0], arguments: val[1], type: val[3], directives: val[4], description: get_description(val[0]))
1617
+ return make_node(:FieldDefinition, name: val[0], arguments: val[1], type: val[3], directives: val[4], description: get_description(val[0]), position_source: val[0])
1618
1618
 
1619
1619
  result
1620
1620
  end
@@ -153,7 +153,7 @@ rule
153
153
  | schema_keyword
154
154
 
155
155
  enum_value_definition:
156
- enum_name directives_list_opt { return make_node(:EnumValueDefinition, name: val[0], directives: val[1], description: get_description(val[0])) }
156
+ enum_name directives_list_opt { return make_node(:EnumValueDefinition, name: val[0], directives: val[1], description: get_description(val[0]), position_source: val[0]) }
157
157
 
158
158
  enum_value_definitions:
159
159
  enum_value_definition { return [val[0]] }
@@ -307,16 +307,16 @@ rule
307
307
  | IMPLEMENTS legacy_interfaces_list { return val[1] }
308
308
 
309
309
  interfaces_list:
310
- name { return [make_node(:TypeName, name: val[0])] }
311
- | interfaces_list AMP name { val[0] << make_node(:TypeName, name: val[2]) }
310
+ name { return [make_node(:TypeName, name: val[0], position_source: val[0])] }
311
+ | interfaces_list AMP name { val[0] << make_node(:TypeName, name: val[2], position_source: val[2]) }
312
312
 
313
313
  legacy_interfaces_list:
314
- name { return [make_node(:TypeName, name: val[0])] }
315
- | legacy_interfaces_list name { val[0] << make_node(:TypeName, name: val[1]) }
314
+ name { return [make_node(:TypeName, name: val[0], position_source: val[0])] }
315
+ | legacy_interfaces_list name { val[0] << make_node(:TypeName, name: val[1], position_source: val[1]) }
316
316
 
317
317
  input_value_definition:
318
318
  name COLON type default_value_opt directives_list_opt {
319
- return make_node(:InputValueDefinition, name: val[0], type: val[2], default_value: val[3], directives: val[4], description: get_description(val[0]))
319
+ return make_node(:InputValueDefinition, name: val[0], type: val[2], default_value: val[3], directives: val[4], description: get_description(val[0]), position_source: val[0])
320
320
  }
321
321
 
322
322
  input_value_definition_list:
@@ -329,7 +329,7 @@ rule
329
329
 
330
330
  field_definition:
331
331
  name arguments_definitions_opt COLON type directives_list_opt {
332
- return make_node(:FieldDefinition, name: val[0], arguments: val[1], type: val[3], directives: val[4], description: get_description(val[0]))
332
+ return make_node(:FieldDefinition, name: val[0], arguments: val[1], type: val[3], directives: val[4], description: get_description(val[0]), position_source: val[0])
333
333
  }
334
334
 
335
335
  field_definition_list:
@@ -102,6 +102,18 @@ module GraphQL
102
102
 
103
103
  NO_ARGS = NoArguments.new({}, context: nil, defaults_used: Set.new)
104
104
 
105
+ # Convert this instance into valid Ruby keyword arguments
106
+ # @return [{Symbol=>Object}]
107
+ def to_kwargs
108
+ ruby_kwargs = {}
109
+
110
+ keys.each do |key|
111
+ ruby_kwargs[Schema::Member::BuildType.underscore(key).to_sym] = self[key]
112
+ end
113
+
114
+ ruby_kwargs
115
+ end
116
+
105
117
  private
106
118
 
107
119
  class ArgumentValue