graphql 1.13.17 → 2.0.20
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/install_generator.rb +1 -1
- data/lib/generators/graphql/relay.rb +3 -17
- data/lib/generators/graphql/templates/schema.erb +3 -0
- data/lib/graphql/analysis/ast/field_usage.rb +3 -1
- data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -1
- data/lib/graphql/analysis/ast/query_complexity.rb +1 -1
- data/lib/graphql/analysis/ast/query_depth.rb +0 -1
- data/lib/graphql/analysis/ast/visitor.rb +43 -36
- data/lib/graphql/analysis/ast.rb +2 -12
- data/lib/graphql/analysis.rb +0 -7
- data/lib/graphql/backtrace/table.rb +2 -20
- data/lib/graphql/backtrace/tracer.rb +2 -3
- data/lib/graphql/backtrace.rb +2 -8
- data/lib/graphql/dataloader/null_dataloader.rb +3 -1
- data/lib/graphql/dataloader/source.rb +9 -0
- data/lib/graphql/dataloader.rb +4 -1
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/errors.rb +12 -82
- data/lib/graphql/execution/interpreter/resolve.rb +26 -0
- data/lib/graphql/execution/interpreter/runtime.rb +159 -120
- data/lib/graphql/execution/interpreter.rb +187 -78
- data/lib/graphql/execution/lazy.rb +7 -21
- data/lib/graphql/execution/lookahead.rb +44 -40
- data/lib/graphql/execution/multiplex.rb +3 -174
- data/lib/graphql/execution.rb +11 -4
- data/lib/graphql/introspection/directive_type.rb +2 -2
- data/lib/graphql/introspection/dynamic_fields.rb +3 -8
- data/lib/graphql/introspection/entry_points.rb +2 -15
- data/lib/graphql/introspection/field_type.rb +1 -1
- data/lib/graphql/introspection/schema_type.rb +2 -2
- data/lib/graphql/introspection/type_type.rb +13 -6
- data/lib/graphql/introspection.rb +4 -3
- data/lib/graphql/language/document_from_schema_definition.rb +18 -35
- data/lib/graphql/language/lexer.rb +216 -1488
- data/lib/graphql/language/nodes.rb +65 -39
- data/lib/graphql/language/parser.rb +376 -364
- data/lib/graphql/language/parser.y +49 -44
- data/lib/graphql/language/printer.rb +37 -21
- data/lib/graphql/language/visitor.rb +191 -83
- data/lib/graphql/pagination/active_record_relation_connection.rb +0 -8
- data/lib/graphql/pagination/array_connection.rb +4 -2
- data/lib/graphql/pagination/connection.rb +31 -4
- data/lib/graphql/pagination/connections.rb +3 -28
- data/lib/graphql/pagination/relation_connection.rb +2 -0
- data/lib/graphql/query/context.rb +155 -196
- data/lib/graphql/query/input_validation_result.rb +1 -1
- data/lib/graphql/query/null_context.rb +0 -3
- data/lib/graphql/query/validation_pipeline.rb +10 -34
- data/lib/graphql/query/variables.rb +7 -20
- data/lib/graphql/query.rb +32 -42
- data/lib/graphql/railtie.rb +0 -104
- data/lib/graphql/rake_task/validate.rb +1 -1
- data/lib/graphql/rake_task.rb +29 -1
- data/lib/graphql/relay/range_add.rb +9 -20
- data/lib/graphql/relay.rb +0 -15
- data/lib/graphql/schema/addition.rb +7 -9
- data/lib/graphql/schema/argument.rb +36 -43
- data/lib/graphql/schema/build_from_definition.rb +32 -18
- data/lib/graphql/schema/directive/one_of.rb +12 -0
- data/lib/graphql/schema/directive/transform.rb +1 -1
- data/lib/graphql/schema/directive.rb +12 -23
- data/lib/graphql/schema/enum.rb +28 -39
- data/lib/graphql/schema/enum_value.rb +5 -25
- data/lib/graphql/schema/field/connection_extension.rb +4 -0
- data/lib/graphql/schema/field.rb +237 -339
- data/lib/graphql/schema/input_object.rb +56 -67
- data/lib/graphql/schema/interface.rb +0 -35
- data/lib/graphql/schema/introspection_system.rb +3 -8
- data/lib/graphql/schema/late_bound_type.rb +8 -2
- data/lib/graphql/schema/list.rb +0 -6
- data/lib/graphql/schema/loader.rb +1 -2
- data/lib/graphql/schema/member/base_dsl_methods.rb +17 -19
- data/lib/graphql/schema/member/build_type.rb +5 -7
- data/lib/graphql/schema/member/has_arguments.rb +146 -55
- data/lib/graphql/schema/member/has_ast_node.rb +12 -0
- data/lib/graphql/schema/member/has_deprecation_reason.rb +3 -4
- data/lib/graphql/schema/member/has_directives.rb +81 -59
- data/lib/graphql/schema/member/has_fields.rb +17 -4
- data/lib/graphql/schema/member/has_interfaces.rb +49 -10
- data/lib/graphql/schema/member/has_validators.rb +31 -5
- data/lib/graphql/schema/member/relay_shortcuts.rb +47 -2
- data/lib/graphql/schema/member/type_system_helpers.rb +17 -0
- data/lib/graphql/schema/member/validates_input.rb +1 -1
- data/lib/graphql/schema/member.rb +0 -6
- data/lib/graphql/schema/mutation.rb +0 -9
- data/lib/graphql/schema/non_null.rb +1 -7
- data/lib/graphql/schema/object.rb +15 -52
- data/lib/graphql/schema/relay_classic_mutation.rb +53 -42
- data/lib/graphql/schema/resolver/has_payload_type.rb +20 -10
- data/lib/graphql/schema/resolver.rb +41 -42
- data/lib/graphql/schema/scalar.rb +7 -22
- data/lib/graphql/schema/subscription.rb +0 -7
- data/lib/graphql/schema/timeout.rb +24 -28
- data/lib/graphql/schema/type_membership.rb +3 -0
- data/lib/graphql/schema/union.rb +10 -17
- data/lib/graphql/schema/warden.rb +34 -8
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +241 -973
- data/lib/graphql/static_validation/all_rules.rb +1 -0
- data/lib/graphql/static_validation/base_visitor.rb +4 -21
- data/lib/graphql/static_validation/definition_dependencies.rb +7 -1
- data/lib/graphql/static_validation/error.rb +2 -2
- data/lib/graphql/static_validation/literal_validator.rb +19 -1
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +11 -5
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +12 -12
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +66 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +29 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +12 -6
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +1 -1
- data/lib/graphql/static_validation/validator.rb +3 -25
- data/lib/graphql/static_validation.rb +0 -2
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +7 -1
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +38 -1
- data/lib/graphql/subscriptions/event.rb +3 -8
- data/lib/graphql/subscriptions/instrumentation.rb +0 -51
- data/lib/graphql/subscriptions.rb +32 -20
- data/lib/graphql/tracing/active_support_notifications_trace.rb +16 -0
- data/lib/graphql/tracing/appoptics_trace.rb +231 -0
- data/lib/graphql/tracing/appsignal_trace.rb +71 -0
- data/lib/graphql/tracing/data_dog_trace.rb +148 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +2 -0
- data/lib/graphql/tracing/new_relic_trace.rb +75 -0
- data/lib/graphql/tracing/notifications_trace.rb +41 -0
- data/lib/graphql/tracing/platform_trace.rb +107 -0
- data/lib/graphql/tracing/platform_tracing.rb +26 -40
- data/lib/graphql/tracing/prometheus_trace.rb +89 -0
- data/lib/graphql/tracing/prometheus_tracing.rb +3 -3
- data/lib/graphql/tracing/scout_trace.rb +72 -0
- data/lib/graphql/tracing/statsd_trace.rb +56 -0
- data/lib/graphql/tracing.rb +136 -40
- data/lib/graphql/type_kinds.rb +6 -3
- data/lib/graphql/types/iso_8601_date.rb +4 -1
- data/lib/graphql/types/iso_8601_date_time.rb +4 -0
- data/lib/graphql/types/relay/base_connection.rb +16 -6
- data/lib/graphql/types/relay/connection_behaviors.rb +29 -27
- data/lib/graphql/types/relay/edge_behaviors.rb +16 -5
- data/lib/graphql/types/relay/node_behaviors.rb +12 -2
- data/lib/graphql/types/relay/page_info_behaviors.rb +7 -2
- data/lib/graphql/types/relay.rb +0 -3
- data/lib/graphql/types/string.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +13 -74
- metadata +30 -133
- data/lib/graphql/analysis/analyze_query.rb +0 -98
- data/lib/graphql/analysis/field_usage.rb +0 -45
- data/lib/graphql/analysis/max_query_complexity.rb +0 -26
- data/lib/graphql/analysis/max_query_depth.rb +0 -26
- data/lib/graphql/analysis/query_complexity.rb +0 -88
- data/lib/graphql/analysis/query_depth.rb +0 -43
- data/lib/graphql/analysis/reducer_state.rb +0 -48
- data/lib/graphql/argument.rb +0 -131
- data/lib/graphql/authorization.rb +0 -82
- data/lib/graphql/backtrace/legacy_tracer.rb +0 -56
- data/lib/graphql/backwards_compatibility.rb +0 -61
- data/lib/graphql/base_type.rb +0 -232
- data/lib/graphql/boolean_type.rb +0 -2
- data/lib/graphql/compatibility/execution_specification/counter_schema.rb +0 -53
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +0 -200
- data/lib/graphql/compatibility/execution_specification.rb +0 -436
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
- data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -215
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -87
- data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -266
- data/lib/graphql/compatibility/schema_parser_specification.rb +0 -682
- data/lib/graphql/compatibility.rb +0 -5
- data/lib/graphql/define/assign_argument.rb +0 -12
- data/lib/graphql/define/assign_connection.rb +0 -13
- data/lib/graphql/define/assign_enum_value.rb +0 -18
- data/lib/graphql/define/assign_global_id_field.rb +0 -11
- data/lib/graphql/define/assign_mutation_function.rb +0 -34
- data/lib/graphql/define/assign_object_field.rb +0 -42
- data/lib/graphql/define/defined_object_proxy.rb +0 -53
- data/lib/graphql/define/instance_definable.rb +0 -255
- data/lib/graphql/define/no_definition_error.rb +0 -7
- data/lib/graphql/define/non_null_with_bang.rb +0 -16
- data/lib/graphql/define/type_definer.rb +0 -31
- data/lib/graphql/define.rb +0 -31
- data/lib/graphql/deprecated_dsl.rb +0 -55
- data/lib/graphql/directive/deprecated_directive.rb +0 -2
- data/lib/graphql/directive/include_directive.rb +0 -2
- data/lib/graphql/directive/skip_directive.rb +0 -2
- data/lib/graphql/directive.rb +0 -107
- data/lib/graphql/enum_type.rb +0 -133
- data/lib/graphql/execution/execute.rb +0 -333
- data/lib/graphql/execution/flatten.rb +0 -40
- data/lib/graphql/execution/instrumentation.rb +0 -92
- data/lib/graphql/execution/lazy/resolve.rb +0 -91
- data/lib/graphql/execution/typecast.rb +0 -50
- data/lib/graphql/field/resolve.rb +0 -59
- data/lib/graphql/field.rb +0 -226
- data/lib/graphql/float_type.rb +0 -2
- data/lib/graphql/function.rb +0 -128
- data/lib/graphql/id_type.rb +0 -2
- data/lib/graphql/input_object_type.rb +0 -138
- data/lib/graphql/int_type.rb +0 -2
- data/lib/graphql/interface_type.rb +0 -72
- data/lib/graphql/internal_representation/document.rb +0 -27
- data/lib/graphql/internal_representation/node.rb +0 -206
- data/lib/graphql/internal_representation/print.rb +0 -51
- data/lib/graphql/internal_representation/rewrite.rb +0 -184
- data/lib/graphql/internal_representation/scope.rb +0 -88
- data/lib/graphql/internal_representation/visit.rb +0 -36
- data/lib/graphql/internal_representation.rb +0 -7
- data/lib/graphql/language/lexer.rl +0 -260
- data/lib/graphql/list_type.rb +0 -80
- data/lib/graphql/non_null_type.rb +0 -71
- data/lib/graphql/object_type.rb +0 -130
- data/lib/graphql/query/arguments.rb +0 -189
- data/lib/graphql/query/arguments_cache.rb +0 -24
- data/lib/graphql/query/executor.rb +0 -52
- data/lib/graphql/query/literal_input.rb +0 -136
- data/lib/graphql/query/serial_execution/field_resolution.rb +0 -92
- data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -19
- data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -23
- data/lib/graphql/query/serial_execution/value_resolution.rb +0 -87
- data/lib/graphql/query/serial_execution.rb +0 -40
- data/lib/graphql/relay/array_connection.rb +0 -83
- data/lib/graphql/relay/base_connection.rb +0 -189
- data/lib/graphql/relay/connection_instrumentation.rb +0 -54
- data/lib/graphql/relay/connection_resolve.rb +0 -43
- data/lib/graphql/relay/connection_type.rb +0 -54
- data/lib/graphql/relay/edge.rb +0 -27
- data/lib/graphql/relay/edge_type.rb +0 -19
- data/lib/graphql/relay/edges_instrumentation.rb +0 -39
- data/lib/graphql/relay/global_id_resolve.rb +0 -17
- data/lib/graphql/relay/mongo_relation_connection.rb +0 -50
- data/lib/graphql/relay/mutation/instrumentation.rb +0 -23
- data/lib/graphql/relay/mutation/resolve.rb +0 -56
- data/lib/graphql/relay/mutation/result.rb +0 -38
- data/lib/graphql/relay/mutation.rb +0 -106
- data/lib/graphql/relay/node.rb +0 -39
- data/lib/graphql/relay/page_info.rb +0 -7
- data/lib/graphql/relay/relation_connection.rb +0 -188
- data/lib/graphql/relay/type_extensions.rb +0 -32
- data/lib/graphql/scalar_type.rb +0 -91
- data/lib/graphql/schema/catchall_middleware.rb +0 -35
- data/lib/graphql/schema/default_parse_error.rb +0 -10
- data/lib/graphql/schema/default_type_error.rb +0 -17
- data/lib/graphql/schema/member/accepts_definition.rb +0 -164
- data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -58
- data/lib/graphql/schema/member/instrumentation.rb +0 -131
- data/lib/graphql/schema/middleware_chain.rb +0 -82
- data/lib/graphql/schema/possible_types.rb +0 -44
- data/lib/graphql/schema/rescue_middleware.rb +0 -60
- data/lib/graphql/schema/timeout_middleware.rb +0 -88
- data/lib/graphql/schema/traversal.rb +0 -228
- data/lib/graphql/schema/validation.rb +0 -313
- data/lib/graphql/static_validation/default_visitor.rb +0 -15
- data/lib/graphql/static_validation/no_validate_visitor.rb +0 -10
- data/lib/graphql/string_type.rb +0 -2
- data/lib/graphql/subscriptions/subscription_root.rb +0 -76
- data/lib/graphql/tracing/skylight_tracing.rb +0 -70
- data/lib/graphql/types/relay/default_relay.rb +0 -31
- data/lib/graphql/types/relay/node_field.rb +0 -24
- data/lib/graphql/types/relay/nodes_field.rb +0 -43
- data/lib/graphql/union_type.rb +0 -115
- data/lib/graphql/upgrader/member.rb +0 -937
- data/lib/graphql/upgrader/schema.rb +0 -38
@@ -162,7 +162,7 @@ rule
|
|
162
162
|
| schema_keyword
|
163
163
|
|
164
164
|
enum_value_definition:
|
165
|
-
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]
|
165
|
+
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][1], position_source: val[0] || val[1]) }
|
166
166
|
|
167
167
|
enum_value_definitions:
|
168
168
|
enum_value_definition { result = [val[0]] }
|
@@ -180,9 +180,9 @@ rule
|
|
180
180
|
name COLON input_value { result = make_node(:Argument, name: val[0], value: val[2], position_source: val[0])}
|
181
181
|
|
182
182
|
literal_value:
|
183
|
-
FLOAT { result = val[0].to_f }
|
184
|
-
| INT { result = val[0].to_i }
|
185
|
-
| STRING { result = val[0]
|
183
|
+
FLOAT { result = val[0][3].to_f }
|
184
|
+
| INT { result = val[0][3].to_i }
|
185
|
+
| STRING { result = val[0][3] }
|
186
186
|
| TRUE { result = true }
|
187
187
|
| FALSE { result = false }
|
188
188
|
| null_value
|
@@ -284,14 +284,14 @@ rule
|
|
284
284
|
| directive_definition
|
285
285
|
|
286
286
|
schema_definition:
|
287
|
-
SCHEMA directives_list_opt LCURLY operation_type_definition_list RCURLY { result = make_node(:SchemaDefinition, position_source: val[0], definition_line: val[0]
|
287
|
+
SCHEMA directives_list_opt LCURLY operation_type_definition_list RCURLY { result = make_node(:SchemaDefinition, position_source: val[0], definition_line: val[0][1], directives: val[1], **val[3]) }
|
288
288
|
|
289
289
|
operation_type_definition_list:
|
290
290
|
operation_type_definition
|
291
291
|
| operation_type_definition_list operation_type_definition { result = val[0].merge(val[1]) }
|
292
292
|
|
293
293
|
operation_type_definition:
|
294
|
-
operation_type COLON name { result = { val[0].
|
294
|
+
operation_type COLON name { result = { val[0][3].to_sym => val[2] } }
|
295
295
|
|
296
296
|
type_definition:
|
297
297
|
scalar_type_definition
|
@@ -321,13 +321,13 @@ rule
|
|
321
321
|
|
322
322
|
object_type_extension:
|
323
323
|
/* TODO - This first one shouldn't be necessary but parser is getting confused */
|
324
|
-
EXTEND TYPE name implements
|
325
|
-
| EXTEND TYPE name implements_opt directives_list_opt
|
324
|
+
EXTEND TYPE name implements field_definition_list_opt { result = make_node(:ObjectTypeExtension, name: val[2], interfaces: val[3], directives: [], fields: val[4], position_source: val[0]) }
|
325
|
+
| EXTEND TYPE name implements_opt directives_list_opt field_definition_list_opt { result = make_node(:ObjectTypeExtension, name: val[2], interfaces: val[3], directives: val[4], fields: val[5], position_source: val[0]) }
|
326
326
|
| 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]) }
|
327
327
|
| EXTEND TYPE name implements { result = make_node(:ObjectTypeExtension, name: val[2], interfaces: val[3], directives: [], fields: [], position_source: val[0]) }
|
328
328
|
|
329
329
|
interface_type_extension:
|
330
|
-
EXTEND INTERFACE name implements_opt directives_list_opt
|
330
|
+
EXTEND INTERFACE name implements_opt directives_list_opt field_definition_list_opt { result = make_node(:InterfaceTypeExtension, name: val[2], interfaces: val[3], directives: val[4], fields: val[5], position_source: val[0]) }
|
331
331
|
| EXTEND INTERFACE name implements_opt directives_list { result = make_node(:InterfaceTypeExtension, name: val[2], interfaces: val[3], directives: val[4], fields: [], position_source: val[0]) }
|
332
332
|
| EXTEND INTERFACE name implements { result = make_node(:InterfaceTypeExtension, name: val[2], interfaces: val[3], directives: [], fields: [], position_source: val[0]) }
|
333
333
|
|
@@ -351,12 +351,12 @@ rule
|
|
351
351
|
|
352
352
|
scalar_type_definition:
|
353
353
|
description_opt SCALAR name directives_list_opt {
|
354
|
-
result = make_node(:ScalarTypeDefinition, name: val[2], directives: val[3], description: val[0] || get_description(val[1]), definition_line: val[1]
|
354
|
+
result = make_node(:ScalarTypeDefinition, name: val[2], directives: val[3], description: val[0] || get_description(val[1]), definition_line: val[1][1], position_source: val[0] || val[1])
|
355
355
|
}
|
356
356
|
|
357
357
|
object_type_definition:
|
358
|
-
description_opt TYPE name implements_opt directives_list_opt
|
359
|
-
result = make_node(:ObjectTypeDefinition, name: val[2], interfaces: val[3], directives: val[4], fields: val[
|
358
|
+
description_opt TYPE name implements_opt directives_list_opt field_definition_list_opt {
|
359
|
+
result = make_node(:ObjectTypeDefinition, name: val[2], interfaces: val[3], directives: val[4], fields: val[5], description: val[0] || get_description(val[1]), definition_line: val[1][1], position_source: val[0] || val[1])
|
360
360
|
}
|
361
361
|
|
362
362
|
implements_opt:
|
@@ -378,7 +378,7 @@ rule
|
|
378
378
|
|
379
379
|
input_value_definition:
|
380
380
|
description_opt name COLON type default_value_opt directives_list_opt {
|
381
|
-
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]
|
381
|
+
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][1], position_source: val[0] || val[1])
|
382
382
|
}
|
383
383
|
|
384
384
|
input_value_definition_list:
|
@@ -391,17 +391,21 @@ rule
|
|
391
391
|
|
392
392
|
field_definition:
|
393
393
|
description_opt name arguments_definitions_opt COLON type directives_list_opt {
|
394
|
-
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]
|
394
|
+
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][1], position_source: val[0] || val[1])
|
395
395
|
}
|
396
396
|
|
397
|
-
|
397
|
+
field_definition_list_opt:
|
398
398
|
/* none */ { result = EMPTY_ARRAY }
|
399
|
+
| LCURLY field_definition_list RCURLY { result = val[1] }
|
400
|
+
|
401
|
+
field_definition_list:
|
402
|
+
/* none - this is not actually valid but graphql-ruby used to print this */ { result = EMPTY_ARRAY }
|
399
403
|
| field_definition { result = [val[0]] }
|
400
404
|
| field_definition_list field_definition { val[0] << val[1] }
|
401
405
|
|
402
406
|
interface_type_definition:
|
403
|
-
description_opt INTERFACE name implements_opt directives_list_opt
|
404
|
-
result = make_node(:InterfaceTypeDefinition, name: val[2], interfaces: val[3], directives: val[4], fields: val[
|
407
|
+
description_opt INTERFACE name implements_opt directives_list_opt field_definition_list_opt {
|
408
|
+
result = make_node(:InterfaceTypeDefinition, name: val[2], interfaces: val[3], directives: val[4], fields: val[5], description: val[0] || get_description(val[1]), definition_line: val[1][1], position_source: val[0] || val[1])
|
405
409
|
}
|
406
410
|
|
407
411
|
union_members:
|
@@ -410,22 +414,22 @@ rule
|
|
410
414
|
|
411
415
|
union_type_definition:
|
412
416
|
description_opt UNION name directives_list_opt EQUALS union_members {
|
413
|
-
result = make_node(:UnionTypeDefinition, name: val[2], directives: val[3], types: val[5], description: val[0] || get_description(val[1]), definition_line: val[1]
|
417
|
+
result = make_node(:UnionTypeDefinition, name: val[2], directives: val[3], types: val[5], description: val[0] || get_description(val[1]), definition_line: val[1][1], position_source: val[0] || val[1])
|
414
418
|
}
|
415
419
|
|
416
420
|
enum_type_definition:
|
417
421
|
description_opt ENUM name directives_list_opt LCURLY enum_value_definitions RCURLY {
|
418
|
-
result = make_node(:EnumTypeDefinition, name: val[2], directives: val[3], values: val[5], description: val[0] || get_description(val[1]), definition_line: val[1]
|
422
|
+
result = make_node(:EnumTypeDefinition, name: val[2], directives: val[3], values: val[5], description: val[0] || get_description(val[1]), definition_line: val[1][1], position_source: val[0] || val[1])
|
419
423
|
}
|
420
424
|
|
421
425
|
input_object_type_definition:
|
422
426
|
description_opt INPUT name directives_list_opt LCURLY input_value_definition_list RCURLY {
|
423
|
-
result = make_node(:InputObjectTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), definition_line: val[1]
|
427
|
+
result = make_node(:InputObjectTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), definition_line: val[1][1], position_source: val[0] || val[1])
|
424
428
|
}
|
425
429
|
|
426
430
|
directive_definition:
|
427
431
|
description_opt DIRECTIVE DIR_SIGN name arguments_definitions_opt directive_repeatable_opt ON directive_locations {
|
428
|
-
result = make_node(:DirectiveDefinition, name: val[3], arguments: val[4], locations: val[7], repeatable: !!val[5], description: val[0] || get_description(val[1]), definition_line: val[1]
|
432
|
+
result = make_node(:DirectiveDefinition, name: val[3], arguments: val[4], locations: val[7], repeatable: !!val[5], description: val[0] || get_description(val[1]), definition_line: val[1][1], position_source: val[0] || val[1])
|
429
433
|
}
|
430
434
|
|
431
435
|
directive_repeatable_opt:
|
@@ -433,8 +437,8 @@ rule
|
|
433
437
|
| REPEATABLE
|
434
438
|
|
435
439
|
directive_locations:
|
436
|
-
name { result = [make_node(:DirectiveLocation, name: val[0]
|
437
|
-
| directive_locations PIPE name { val[0] << make_node(:DirectiveLocation, name: val[2]
|
440
|
+
name { result = [make_node(:DirectiveLocation, name: val[0][3], position_source: val[0])] }
|
441
|
+
| directive_locations PIPE name { val[0] << make_node(:DirectiveLocation, name: val[2][3], position_source: val[2]) }
|
438
442
|
end
|
439
443
|
|
440
444
|
---- header ----
|
@@ -444,22 +448,22 @@ end
|
|
444
448
|
|
445
449
|
EMPTY_ARRAY = [].freeze
|
446
450
|
|
447
|
-
def initialize(query_string, filename:,
|
451
|
+
def initialize(query_string, filename:, trace: Tracing::NullTrace)
|
448
452
|
raise GraphQL::ParseError.new("No query string was present", nil, nil, query_string) if query_string.nil?
|
449
453
|
@query_string = query_string
|
450
454
|
@filename = filename
|
451
|
-
@
|
455
|
+
@trace = trace
|
452
456
|
@reused_next_token = [nil, nil]
|
453
457
|
end
|
454
458
|
|
455
459
|
def parse_document
|
456
460
|
@document ||= begin
|
457
461
|
# Break the string into tokens
|
458
|
-
@
|
459
|
-
@tokens ||= GraphQL.
|
462
|
+
@trace.lex(query_string: @query_string) do
|
463
|
+
@tokens ||= GraphQL::Language::Lexer.tokenize(@query_string)
|
460
464
|
end
|
461
465
|
# From the tokens, build an AST
|
462
|
-
@
|
466
|
+
@trace.parse(query_string: @query_string) do
|
463
467
|
if @tokens.empty?
|
464
468
|
raise GraphQL::ParseError.new("Unexpected end of document", nil, nil, @query_string)
|
465
469
|
else
|
@@ -472,17 +476,17 @@ end
|
|
472
476
|
class << self
|
473
477
|
attr_accessor :cache
|
474
478
|
|
475
|
-
def parse(query_string, filename: nil,
|
476
|
-
new(query_string, filename: filename,
|
479
|
+
def parse(query_string, filename: nil, trace: GraphQL::Tracing::NullTrace)
|
480
|
+
new(query_string, filename: filename, trace: trace).parse_document
|
477
481
|
end
|
478
482
|
|
479
|
-
def parse_file(filename,
|
483
|
+
def parse_file(filename, trace: GraphQL::Tracing::NullTrace)
|
480
484
|
if cache
|
481
485
|
cache.fetch(filename) do
|
482
|
-
parse(File.read(filename), filename: filename,
|
486
|
+
parse(File.read(filename), filename: filename, trace: trace)
|
483
487
|
end
|
484
488
|
else
|
485
|
-
parse(File.read(filename), filename: filename,
|
489
|
+
parse(File.read(filename), filename: filename, trace: trace)
|
486
490
|
end
|
487
491
|
end
|
488
492
|
end
|
@@ -494,7 +498,7 @@ def next_token
|
|
494
498
|
if lexer_token.nil?
|
495
499
|
nil
|
496
500
|
else
|
497
|
-
@reused_next_token[0] = lexer_token
|
501
|
+
@reused_next_token[0] = lexer_token[0]
|
498
502
|
@reused_next_token[1] = lexer_token
|
499
503
|
@reused_next_token
|
500
504
|
end
|
@@ -505,13 +509,13 @@ def get_description(token)
|
|
505
509
|
|
506
510
|
loop do
|
507
511
|
prev_token = token
|
508
|
-
token = token
|
512
|
+
token = token[4]
|
509
513
|
|
510
514
|
break if token.nil?
|
511
|
-
break if token
|
512
|
-
break if prev_token
|
515
|
+
break if token[0] != :COMMENT
|
516
|
+
break if prev_token[1] != token[1] + 1
|
513
517
|
|
514
|
-
comments.unshift(token.
|
518
|
+
comments.unshift(token[3].sub(/^#\s*/, ""))
|
515
519
|
end
|
516
520
|
|
517
521
|
return nil if comments.empty?
|
@@ -527,11 +531,12 @@ def on_error(parser_token_id, lexer_token, vstack)
|
|
527
531
|
if parser_token_name.nil?
|
528
532
|
raise GraphQL::ParseError.new("Parse Error on unknown token: {token_id: #{parser_token_id}, lexer_token: #{lexer_token}} from #{@query_string}", nil, nil, @query_string, filename: @filename)
|
529
533
|
else
|
530
|
-
line
|
531
|
-
|
532
|
-
|
534
|
+
line = lexer_token[1]
|
535
|
+
col = lexer_token[2]
|
536
|
+
if lexer_token[0] == :BAD_UNICODE_ESCAPE
|
537
|
+
raise GraphQL::ParseError.new("Parse error on bad Unicode escape sequence: #{lexer_token[3].inspect} (#{parser_token_name}) at [#{line}, #{col}]", line, col, @query_string, filename: @filename)
|
533
538
|
else
|
534
|
-
raise GraphQL::ParseError.new("Parse error on #{lexer_token.
|
539
|
+
raise GraphQL::ParseError.new("Parse error on #{lexer_token[3].inspect} (#{parser_token_name}) at [#{line}, #{col}]", line, col, @query_string, filename: @filename)
|
535
540
|
end
|
536
541
|
end
|
537
542
|
end
|
@@ -539,8 +544,8 @@ end
|
|
539
544
|
|
540
545
|
def make_node(node_name, assigns)
|
541
546
|
assigns.each do |key, value|
|
542
|
-
if key != :position_source && value.is_a?(
|
543
|
-
assigns[key] = value
|
547
|
+
if key != :position_source && value.is_a?(Array) && value[0].is_a?(Symbol)
|
548
|
+
assigns[key] = value[3]
|
544
549
|
end
|
545
550
|
end
|
546
551
|
|
@@ -132,10 +132,11 @@ module GraphQL
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def print_schema_definition(schema)
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
135
|
+
has_conventional_names = (schema.query.nil? || schema.query == 'Query') &&
|
136
|
+
(schema.mutation.nil? || schema.mutation == 'Mutation') &&
|
137
|
+
(schema.subscription.nil? || schema.subscription == 'Subscription')
|
138
|
+
|
139
|
+
if has_conventional_names && schema.directives.empty?
|
139
140
|
return
|
140
141
|
end
|
141
142
|
|
@@ -145,14 +146,22 @@ module GraphQL
|
|
145
146
|
out << "\n "
|
146
147
|
out << print_node(dir)
|
147
148
|
end
|
148
|
-
|
149
|
-
|
150
|
-
|
149
|
+
if !has_conventional_names
|
150
|
+
out << "\n"
|
151
|
+
end
|
151
152
|
end
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
153
|
+
|
154
|
+
if !has_conventional_names
|
155
|
+
if schema.directives.empty?
|
156
|
+
out << " "
|
157
|
+
end
|
158
|
+
out << "{\n"
|
159
|
+
out << " query: #{schema.query}\n" if schema.query
|
160
|
+
out << " mutation: #{schema.mutation}\n" if schema.mutation
|
161
|
+
out << " subscription: #{schema.subscription}\n" if schema.subscription
|
162
|
+
out << "}"
|
163
|
+
end
|
164
|
+
out
|
156
165
|
end
|
157
166
|
|
158
167
|
def print_scalar_type_definition(scalar_type)
|
@@ -236,12 +245,15 @@ module GraphQL
|
|
236
245
|
out = print_description(input_object_type)
|
237
246
|
out << "input #{input_object_type.name}"
|
238
247
|
out << print_directives(input_object_type.directives)
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
248
|
+
if !input_object_type.fields.empty?
|
249
|
+
out << " {\n"
|
250
|
+
input_object_type.fields.each.with_index do |field, i|
|
251
|
+
out << print_description(field, indent: ' ', first_in_block: i == 0)
|
252
|
+
out << " #{print_input_value_definition(field)}\n"
|
253
|
+
end
|
254
|
+
out << "}"
|
243
255
|
end
|
244
|
-
out
|
256
|
+
out
|
245
257
|
end
|
246
258
|
|
247
259
|
def print_directive_definition(directive)
|
@@ -267,12 +279,16 @@ module GraphQL
|
|
267
279
|
end
|
268
280
|
|
269
281
|
def print_field_definitions(fields)
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
out
|
282
|
+
if fields.empty?
|
283
|
+
""
|
284
|
+
else
|
285
|
+
out = " {\n".dup
|
286
|
+
fields.each.with_index do |field, i|
|
287
|
+
out << print_description(field, indent: ' ', first_in_block: i == 0)
|
288
|
+
out << " #{print_field_definition(field)}\n"
|
289
|
+
end
|
290
|
+
out << "}"
|
274
291
|
end
|
275
|
-
out << "}"
|
276
292
|
end
|
277
293
|
|
278
294
|
def print_directives(directives)
|
@@ -65,7 +65,9 @@ module GraphQL
|
|
65
65
|
# Visit `document` and all children, applying hooks as you go
|
66
66
|
# @return [void]
|
67
67
|
def visit
|
68
|
-
|
68
|
+
# `@document` may be any kind of node:
|
69
|
+
visit_method = :"#{@document.visit_method}_with_modifications"
|
70
|
+
result = public_send(visit_method, @document, nil)
|
69
71
|
@result = if result.is_a?(Array)
|
70
72
|
result.first
|
71
73
|
else
|
@@ -74,104 +76,210 @@ module GraphQL
|
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
77
|
-
#
|
78
|
-
def
|
79
|
-
|
80
|
-
|
79
|
+
# We don't use `alias` here because it breaks `super`
|
80
|
+
def self.make_visit_methods(ast_node_class)
|
81
|
+
node_method = ast_node_class.visit_method
|
82
|
+
children_of_type = ast_node_class.children_of_type
|
83
|
+
child_visit_method = :"#{node_method}_children"
|
81
84
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
85
|
+
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
86
|
+
# The default implementation for visiting an AST node.
|
87
|
+
# It doesn't _do_ anything, but it continues to visiting the node's children.
|
88
|
+
# To customize this hook, override one of its make_visit_methods (or the base method?)
|
89
|
+
# in your subclasses.
|
90
|
+
#
|
91
|
+
# For compatibility, it calls hook procs, too.
|
92
|
+
# @param node [GraphQL::Language::Nodes::AbstractNode] the node being visited
|
93
|
+
# @param parent [GraphQL::Language::Nodes::AbstractNode, nil] the previously-visited node, or `nil` if this is the root node.
|
94
|
+
# @return [Array, nil] If there were modifications, it returns an array of new nodes, otherwise, it returns `nil`.
|
95
|
+
def #{node_method}(node, parent)
|
96
|
+
if node.equal?(DELETE_NODE)
|
97
|
+
# This might be passed to `super(DELETE_NODE, ...)`
|
98
|
+
# by a user hook, don't want to keep visiting in that case.
|
99
|
+
[node, parent]
|
100
|
+
else
|
101
|
+
# Run hooks if there are any
|
102
|
+
new_node = node
|
103
|
+
no_hooks = !@visitors.key?(node.class)
|
104
|
+
if no_hooks || begin_visit(new_node, parent)
|
105
|
+
#{
|
106
|
+
if method_defined?(child_visit_method)
|
107
|
+
"new_node = #{child_visit_method}(new_node)"
|
108
|
+
elsif children_of_type
|
109
|
+
children_of_type.map do |child_accessor, child_class|
|
110
|
+
"node.#{child_accessor}.each do |child_node|
|
111
|
+
new_child_and_node = #{child_class.visit_method}_with_modifications(child_node, new_node)
|
112
|
+
# Reassign `node` in case the child hook makes a modification
|
113
|
+
if new_child_and_node.is_a?(Array)
|
114
|
+
new_node = new_child_and_node[1]
|
115
|
+
end
|
116
|
+
end"
|
117
|
+
end.join("\n")
|
118
|
+
else
|
119
|
+
""
|
120
|
+
end
|
121
|
+
}
|
122
|
+
end
|
123
|
+
end_visit(new_node, parent) unless no_hooks
|
124
|
+
|
125
|
+
if new_node.equal?(node)
|
126
|
+
[node, parent]
|
127
|
+
else
|
128
|
+
[new_node, parent]
|
106
129
|
end
|
107
130
|
end
|
108
131
|
end
|
109
|
-
end_visit(new_node, parent) unless no_hooks
|
110
132
|
|
111
|
-
|
112
|
-
|
133
|
+
def #{node_method}_with_modifications(node, parent)
|
134
|
+
new_node_and_new_parent = #{node_method}(node, parent)
|
135
|
+
apply_modifications(node, parent, new_node_and_new_parent)
|
136
|
+
end
|
137
|
+
RUBY
|
138
|
+
end
|
139
|
+
|
140
|
+
def on_document_children(document_node)
|
141
|
+
new_node = document_node
|
142
|
+
document_node.children.each do |child_node|
|
143
|
+
visit_method = :"#{child_node.visit_method}_with_modifications"
|
144
|
+
new_child_and_node = public_send(visit_method, child_node, new_node)
|
145
|
+
# Reassign `node` in case the child hook makes a modification
|
146
|
+
if new_child_and_node.is_a?(Array)
|
147
|
+
new_node = new_child_and_node[1]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
new_node
|
151
|
+
end
|
152
|
+
|
153
|
+
def on_field_children(new_node)
|
154
|
+
new_node.arguments.each do |arg_node| # rubocop:disable Development/ContextIsPassedCop
|
155
|
+
new_child_and_node = on_argument_with_modifications(arg_node, new_node)
|
156
|
+
# Reassign `node` in case the child hook makes a modification
|
157
|
+
if new_child_and_node.is_a?(Array)
|
158
|
+
new_node = new_child_and_node[1]
|
159
|
+
end
|
160
|
+
end
|
161
|
+
new_node = visit_directives(new_node)
|
162
|
+
new_node = visit_selections(new_node)
|
163
|
+
new_node
|
164
|
+
end
|
165
|
+
|
166
|
+
def visit_directives(new_node)
|
167
|
+
new_node.directives.each do |dir_node|
|
168
|
+
new_child_and_node = on_directive_with_modifications(dir_node, new_node)
|
169
|
+
# Reassign `node` in case the child hook makes a modification
|
170
|
+
if new_child_and_node.is_a?(Array)
|
171
|
+
new_node = new_child_and_node[1]
|
172
|
+
end
|
173
|
+
end
|
174
|
+
new_node
|
175
|
+
end
|
176
|
+
|
177
|
+
def visit_selections(new_node)
|
178
|
+
new_node.selections.each do |selection|
|
179
|
+
new_child_and_node = case selection
|
180
|
+
when GraphQL::Language::Nodes::Field
|
181
|
+
on_field_with_modifications(selection, new_node)
|
182
|
+
when GraphQL::Language::Nodes::InlineFragment
|
183
|
+
on_inline_fragment_with_modifications(selection, new_node)
|
184
|
+
when GraphQL::Language::Nodes::FragmentSpread
|
185
|
+
on_fragment_spread_with_modifications(selection, new_node)
|
113
186
|
else
|
114
|
-
|
187
|
+
raise ArgumentError, "Invariant: unexpected field selection #{selection.class} (#{selection.inspect})"
|
188
|
+
end
|
189
|
+
# Reassign `node` in case the child hook makes a modification
|
190
|
+
if new_child_and_node.is_a?(Array)
|
191
|
+
new_node = new_child_and_node[1]
|
115
192
|
end
|
116
193
|
end
|
194
|
+
new_node
|
117
195
|
end
|
118
196
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
197
|
+
def on_fragment_definition_children(new_node)
|
198
|
+
new_node = visit_directives(new_node)
|
199
|
+
new_node = visit_selections(new_node)
|
200
|
+
new_node
|
201
|
+
end
|
202
|
+
|
203
|
+
alias :on_inline_fragment_children :on_fragment_definition_children
|
204
|
+
|
205
|
+
def on_operation_definition_children(new_node)
|
206
|
+
new_node.variables.each do |arg_node|
|
207
|
+
new_child_and_node = on_variable_definition_with_modifications(arg_node, new_node)
|
208
|
+
# Reassign `node` in case the child hook makes a modification
|
209
|
+
if new_child_and_node.is_a?(Array)
|
210
|
+
new_node = new_child_and_node[1]
|
126
211
|
end
|
127
|
-
|
212
|
+
end
|
213
|
+
new_node = visit_directives(new_node)
|
214
|
+
new_node = visit_selections(new_node)
|
215
|
+
new_node
|
216
|
+
end
|
217
|
+
|
218
|
+
def on_argument_children(new_node)
|
219
|
+
new_node.children.each do |value_node|
|
220
|
+
new_child_and_node = case value_node
|
221
|
+
when Language::Nodes::VariableIdentifier
|
222
|
+
on_variable_identifier_with_modifications(value_node, new_node)
|
223
|
+
when Language::Nodes::InputObject
|
224
|
+
on_input_object_with_modifications(value_node, new_node)
|
225
|
+
when Language::Nodes::Enum
|
226
|
+
on_enum_with_modifications(value_node, new_node)
|
227
|
+
when Language::Nodes::NullValue
|
228
|
+
on_null_value_with_modifications(value_node, new_node)
|
229
|
+
else
|
230
|
+
raise ArgumentError, "Invariant: unexpected argument value node #{value_node.class} (#{value_node.inspect})"
|
231
|
+
end
|
232
|
+
# Reassign `node` in case the child hook makes a modification
|
233
|
+
if new_child_and_node.is_a?(Array)
|
234
|
+
new_node = new_child_and_node[1]
|
235
|
+
end
|
236
|
+
end
|
237
|
+
new_node
|
128
238
|
end
|
129
239
|
|
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
|
-
|
240
|
+
[
|
241
|
+
Language::Nodes::Argument,
|
242
|
+
Language::Nodes::Directive,
|
243
|
+
Language::Nodes::DirectiveDefinition,
|
244
|
+
Language::Nodes::DirectiveLocation,
|
245
|
+
Language::Nodes::Document,
|
246
|
+
Language::Nodes::Enum,
|
247
|
+
Language::Nodes::EnumTypeDefinition,
|
248
|
+
Language::Nodes::EnumTypeExtension,
|
249
|
+
Language::Nodes::EnumValueDefinition,
|
250
|
+
Language::Nodes::Field,
|
251
|
+
Language::Nodes::FieldDefinition,
|
252
|
+
Language::Nodes::FragmentDefinition,
|
253
|
+
Language::Nodes::FragmentSpread,
|
254
|
+
Language::Nodes::InlineFragment,
|
255
|
+
Language::Nodes::InputObject,
|
256
|
+
Language::Nodes::InputObjectTypeDefinition,
|
257
|
+
Language::Nodes::InputObjectTypeExtension,
|
258
|
+
Language::Nodes::InputValueDefinition,
|
259
|
+
Language::Nodes::InterfaceTypeDefinition,
|
260
|
+
Language::Nodes::InterfaceTypeExtension,
|
261
|
+
Language::Nodes::ListType,
|
262
|
+
Language::Nodes::NonNullType,
|
263
|
+
Language::Nodes::NullValue,
|
264
|
+
Language::Nodes::ObjectTypeDefinition,
|
265
|
+
Language::Nodes::ObjectTypeExtension,
|
266
|
+
Language::Nodes::OperationDefinition,
|
267
|
+
Language::Nodes::ScalarTypeDefinition,
|
268
|
+
Language::Nodes::ScalarTypeExtension,
|
269
|
+
Language::Nodes::SchemaDefinition,
|
270
|
+
Language::Nodes::SchemaExtension,
|
271
|
+
Language::Nodes::TypeName,
|
272
|
+
Language::Nodes::UnionTypeDefinition,
|
273
|
+
Language::Nodes::UnionTypeExtension,
|
274
|
+
Language::Nodes::VariableDefinition,
|
275
|
+
Language::Nodes::VariableIdentifier,
|
276
|
+
].each do |ast_node_class|
|
277
|
+
make_visit_methods(ast_node_class)
|
278
|
+
end
|
165
279
|
|
166
280
|
private
|
167
281
|
|
168
|
-
|
169
|
-
# copy `parent` so that it contains the copy of that node as a child,
|
170
|
-
# then return the copies
|
171
|
-
# If a non-array value is returned, consuming functions should ignore
|
172
|
-
# said value
|
173
|
-
def on_node_with_modifications(node, parent)
|
174
|
-
new_node_and_new_parent = visit_node(node, parent)
|
282
|
+
def apply_modifications(node, parent, new_node_and_new_parent)
|
175
283
|
if new_node_and_new_parent.is_a?(Array)
|
176
284
|
new_node = new_node_and_new_parent[0]
|
177
285
|
new_parent = new_node_and_new_parent[1]
|