graphql 1.9.18 → 1.13.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/generators/graphql/core.rb +21 -10
- data/lib/generators/graphql/enum_generator.rb +4 -10
- data/lib/generators/graphql/field_extractor.rb +31 -0
- data/lib/generators/graphql/input_generator.rb +50 -0
- data/lib/generators/graphql/install/mutation_root_generator.rb +34 -0
- data/lib/generators/graphql/{templates → install/templates}/base_mutation.erb +2 -0
- data/lib/generators/graphql/{templates → install/templates}/mutation_type.erb +2 -0
- data/lib/generators/graphql/install_generator.rb +44 -7
- data/lib/generators/graphql/interface_generator.rb +7 -7
- data/lib/generators/graphql/loader_generator.rb +1 -0
- data/lib/generators/graphql/mutation_create_generator.rb +22 -0
- data/lib/generators/graphql/mutation_delete_generator.rb +22 -0
- data/lib/generators/graphql/mutation_generator.rb +6 -30
- data/lib/generators/graphql/mutation_update_generator.rb +22 -0
- data/lib/generators/graphql/object_generator.rb +28 -12
- data/lib/generators/graphql/orm_mutations_base.rb +40 -0
- data/lib/generators/graphql/relay.rb +63 -0
- data/lib/generators/graphql/relay_generator.rb +21 -0
- data/lib/generators/graphql/scalar_generator.rb +4 -2
- data/lib/generators/graphql/templates/base_argument.erb +2 -0
- data/lib/generators/graphql/templates/base_connection.erb +8 -0
- data/lib/generators/graphql/templates/base_edge.erb +8 -0
- data/lib/generators/graphql/templates/base_enum.erb +2 -0
- data/lib/generators/graphql/templates/base_field.erb +2 -0
- data/lib/generators/graphql/templates/base_input_object.erb +2 -0
- data/lib/generators/graphql/templates/base_interface.erb +2 -0
- data/lib/generators/graphql/templates/base_object.erb +2 -0
- data/lib/generators/graphql/templates/base_scalar.erb +2 -0
- data/lib/generators/graphql/templates/base_union.erb +2 -0
- data/lib/generators/graphql/templates/enum.erb +7 -1
- data/lib/generators/graphql/templates/graphql_controller.erb +16 -12
- data/lib/generators/graphql/templates/input.erb +9 -0
- data/lib/generators/graphql/templates/interface.erb +6 -2
- data/lib/generators/graphql/templates/loader.erb +2 -0
- data/lib/generators/graphql/templates/mutation.erb +3 -1
- data/lib/generators/graphql/templates/mutation_create.erb +20 -0
- data/lib/generators/graphql/templates/mutation_delete.erb +20 -0
- data/lib/generators/graphql/templates/mutation_update.erb +21 -0
- data/lib/generators/graphql/templates/node_type.erb +9 -0
- data/lib/generators/graphql/templates/object.erb +7 -3
- data/lib/generators/graphql/templates/query_type.erb +3 -3
- data/lib/generators/graphql/templates/scalar.erb +5 -1
- data/lib/generators/graphql/templates/schema.erb +22 -27
- data/lib/generators/graphql/templates/union.erb +6 -2
- data/lib/generators/graphql/type_generator.rb +47 -10
- data/lib/generators/graphql/union_generator.rb +5 -5
- data/lib/graphql/analysis/analyze_query.rb +7 -0
- data/lib/graphql/analysis/ast/field_usage.rb +29 -2
- data/lib/graphql/analysis/ast/query_complexity.rb +174 -67
- data/lib/graphql/analysis/ast/visitor.rb +16 -7
- data/lib/graphql/analysis/ast.rb +21 -11
- data/lib/graphql/argument.rb +8 -36
- data/lib/graphql/backtrace/inspect_result.rb +0 -1
- data/lib/graphql/backtrace/legacy_tracer.rb +56 -0
- data/lib/graphql/backtrace/table.rb +44 -5
- data/lib/graphql/backtrace/traced_error.rb +0 -1
- data/lib/graphql/backtrace/tracer.rb +40 -9
- data/lib/graphql/backtrace.rb +28 -19
- data/lib/graphql/backwards_compatibility.rb +2 -1
- data/lib/graphql/base_type.rb +10 -4
- data/lib/graphql/boolean_type.rb +1 -1
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +2 -2
- data/lib/graphql/compatibility/execution_specification.rb +1 -0
- data/lib/graphql/compatibility/lazy_execution_specification.rb +2 -0
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +5 -9
- data/lib/graphql/compatibility/query_parser_specification.rb +2 -0
- data/lib/graphql/compatibility/schema_parser_specification.rb +2 -0
- data/lib/graphql/dataloader/null_dataloader.rb +22 -0
- data/lib/graphql/dataloader/request.rb +19 -0
- data/lib/graphql/dataloader/request_all.rb +19 -0
- data/lib/graphql/dataloader/source.rb +155 -0
- data/lib/graphql/dataloader.rb +308 -0
- data/lib/graphql/date_encoding_error.rb +16 -0
- data/lib/graphql/define/assign_enum_value.rb +1 -1
- data/lib/graphql/define/assign_global_id_field.rb +2 -2
- data/lib/graphql/define/assign_object_field.rb +1 -1
- data/lib/graphql/define/defined_object_proxy.rb +5 -8
- data/lib/graphql/define/instance_definable.rb +60 -110
- data/lib/graphql/define/type_definer.rb +5 -5
- data/lib/graphql/deprecated_dsl.rb +18 -5
- data/lib/graphql/deprecation.rb +9 -0
- data/lib/graphql/directive/deprecated_directive.rb +1 -12
- data/lib/graphql/directive/include_directive.rb +1 -1
- data/lib/graphql/directive/skip_directive.rb +1 -1
- data/lib/graphql/directive.rb +9 -6
- data/lib/graphql/enum_type.rb +14 -74
- data/lib/graphql/execution/directive_checks.rb +2 -2
- data/lib/graphql/execution/errors.rb +110 -8
- data/lib/graphql/execution/execute.rb +8 -1
- data/lib/graphql/execution/instrumentation.rb +1 -1
- data/lib/graphql/execution/interpreter/argument_value.rb +28 -0
- data/lib/graphql/execution/interpreter/arguments.rb +88 -0
- data/lib/graphql/execution/interpreter/arguments_cache.rb +105 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +18 -0
- data/lib/graphql/execution/interpreter/resolve.rb +37 -25
- data/lib/graphql/execution/interpreter/runtime.rb +721 -386
- data/lib/graphql/execution/interpreter.rb +42 -19
- data/lib/graphql/execution/lazy/lazy_method_map.rb +4 -0
- data/lib/graphql/execution/lazy.rb +5 -1
- data/lib/graphql/execution/lookahead.rb +39 -114
- data/lib/graphql/execution/multiplex.rb +50 -25
- data/lib/graphql/field.rb +15 -119
- data/lib/graphql/filter.rb +1 -1
- data/lib/graphql/float_type.rb +1 -1
- data/lib/graphql/function.rb +5 -30
- data/lib/graphql/id_type.rb +1 -1
- data/lib/graphql/input_object_type.rb +9 -25
- data/lib/graphql/int_type.rb +1 -1
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +18 -2
- data/lib/graphql/interface_type.rb +10 -24
- data/lib/graphql/internal_representation/document.rb +2 -2
- data/lib/graphql/internal_representation/rewrite.rb +1 -1
- data/lib/graphql/internal_representation/scope.rb +2 -2
- data/lib/graphql/internal_representation/visit.rb +2 -2
- data/lib/graphql/introspection/base_object.rb +2 -5
- data/lib/graphql/introspection/directive_location_enum.rb +2 -2
- data/lib/graphql/introspection/directive_type.rb +12 -6
- data/lib/graphql/introspection/entry_points.rb +9 -9
- data/lib/graphql/introspection/enum_value_type.rb +2 -2
- data/lib/graphql/introspection/field_type.rb +9 -5
- data/lib/graphql/introspection/input_value_type.rb +41 -11
- data/lib/graphql/introspection/introspection_query.rb +6 -92
- data/lib/graphql/introspection/schema_type.rb +12 -12
- data/lib/graphql/introspection/type_type.rb +27 -17
- data/lib/graphql/introspection.rb +99 -0
- data/lib/graphql/invalid_null_error.rb +18 -0
- data/lib/graphql/language/block_string.rb +20 -5
- data/lib/graphql/language/cache.rb +37 -0
- data/lib/graphql/language/definition_slice.rb +21 -10
- data/lib/graphql/language/document_from_schema_definition.rb +116 -63
- data/lib/graphql/language/lexer.rb +53 -27
- data/lib/graphql/language/lexer.rl +5 -3
- data/lib/graphql/language/nodes.rb +67 -93
- data/lib/graphql/language/parser.rb +929 -896
- data/lib/graphql/language/parser.y +125 -102
- data/lib/graphql/language/printer.rb +11 -2
- data/lib/graphql/language/sanitized_printer.rb +222 -0
- data/lib/graphql/language/token.rb +0 -4
- data/lib/graphql/language/visitor.rb +2 -2
- data/lib/graphql/language.rb +3 -1
- data/lib/graphql/name_validator.rb +2 -7
- data/lib/graphql/non_null_type.rb +0 -10
- data/lib/graphql/object_type.rb +47 -58
- data/lib/graphql/pagination/active_record_relation_connection.rb +85 -0
- data/lib/graphql/pagination/array_connection.rb +77 -0
- data/lib/graphql/pagination/connection.rb +226 -0
- data/lib/graphql/pagination/connections.rb +160 -0
- data/lib/graphql/pagination/mongoid_relation_connection.rb +25 -0
- data/lib/graphql/pagination/relation_connection.rb +226 -0
- data/lib/graphql/pagination/sequel_dataset_connection.rb +28 -0
- data/lib/graphql/pagination.rb +6 -0
- data/lib/graphql/parse_error.rb +0 -1
- data/lib/graphql/query/arguments.rb +6 -4
- data/lib/graphql/query/arguments_cache.rb +1 -2
- data/lib/graphql/query/context.rb +52 -7
- data/lib/graphql/query/executor.rb +0 -1
- data/lib/graphql/query/fingerprint.rb +26 -0
- data/lib/graphql/query/input_validation_result.rb +32 -6
- data/lib/graphql/query/literal_input.rb +31 -11
- data/lib/graphql/query/null_context.rb +24 -8
- data/lib/graphql/query/serial_execution/field_resolution.rb +1 -1
- data/lib/graphql/query/serial_execution.rb +1 -0
- data/lib/graphql/query/validation_pipeline.rb +6 -4
- data/lib/graphql/query/variable_validation_error.rb +3 -3
- data/lib/graphql/query/variables.rb +50 -10
- data/lib/graphql/query.rb +77 -18
- data/lib/graphql/railtie.rb +9 -1
- data/lib/graphql/rake_task/validate.rb +3 -0
- data/lib/graphql/rake_task.rb +12 -9
- data/lib/graphql/relay/array_connection.rb +10 -12
- data/lib/graphql/relay/base_connection.rb +30 -13
- data/lib/graphql/relay/connection_instrumentation.rb +4 -4
- data/lib/graphql/relay/connection_type.rb +18 -4
- data/lib/graphql/relay/edge_type.rb +1 -0
- data/lib/graphql/relay/edges_instrumentation.rb +1 -2
- data/lib/graphql/relay/global_id_resolve.rb +1 -2
- data/lib/graphql/relay/mutation.rb +3 -87
- data/lib/graphql/relay/node.rb +3 -0
- data/lib/graphql/relay/page_info.rb +1 -1
- data/lib/graphql/relay/range_add.rb +27 -9
- data/lib/graphql/relay/relation_connection.rb +8 -10
- data/lib/graphql/relay/type_extensions.rb +2 -0
- data/lib/graphql/rubocop/graphql/base_cop.rb +36 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +43 -0
- data/lib/graphql/rubocop/graphql/default_required_true.rb +43 -0
- data/lib/graphql/rubocop.rb +4 -0
- data/lib/graphql/scalar_type.rb +18 -60
- data/lib/graphql/schema/addition.rb +247 -0
- data/lib/graphql/schema/argument.rb +274 -18
- data/lib/graphql/schema/base_64_encoder.rb +2 -0
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -1
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +13 -5
- data/lib/graphql/schema/build_from_definition.rb +320 -219
- data/lib/graphql/schema/built_in_types.rb +5 -5
- data/lib/graphql/schema/default_type_error.rb +2 -0
- data/lib/graphql/schema/directive/deprecated.rb +18 -0
- data/lib/graphql/schema/directive/feature.rb +1 -1
- data/lib/graphql/schema/directive/flagged.rb +57 -0
- data/lib/graphql/schema/directive/include.rb +2 -2
- data/lib/graphql/schema/directive/skip.rb +2 -2
- data/lib/graphql/schema/directive/transform.rb +14 -2
- data/lib/graphql/schema/directive.rb +130 -6
- data/lib/graphql/schema/enum.rb +121 -12
- data/lib/graphql/schema/enum_value.rb +24 -7
- data/lib/graphql/schema/field/connection_extension.rb +46 -20
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +465 -181
- data/lib/graphql/schema/field_extension.rb +89 -2
- data/lib/graphql/schema/find_inherited_value.rb +17 -1
- data/lib/graphql/schema/finder.rb +16 -14
- data/lib/graphql/schema/input_object.rb +172 -37
- data/lib/graphql/schema/interface.rb +39 -25
- data/lib/graphql/schema/introspection_system.rb +106 -38
- data/lib/graphql/schema/late_bound_type.rb +3 -2
- data/lib/graphql/schema/list.rb +65 -1
- data/lib/graphql/schema/loader.rb +145 -102
- data/lib/graphql/schema/member/accepts_definition.rb +15 -3
- data/lib/graphql/schema/member/base_dsl_methods.rb +34 -28
- data/lib/graphql/schema/member/build_type.rb +19 -8
- data/lib/graphql/schema/member/cached_graphql_definition.rb +34 -2
- data/lib/graphql/schema/member/has_arguments.rb +206 -13
- data/lib/graphql/schema/member/has_ast_node.rb +20 -0
- data/lib/graphql/schema/member/has_deprecation_reason.rb +25 -0
- data/lib/graphql/schema/member/has_directives.rb +98 -0
- data/lib/graphql/schema/member/has_fields.rb +97 -32
- data/lib/graphql/schema/member/has_interfaces.rb +100 -0
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +15 -0
- data/lib/graphql/schema/member/has_validators.rb +31 -0
- data/lib/graphql/schema/member/instrumentation.rb +0 -1
- data/lib/graphql/schema/member/type_system_helpers.rb +3 -3
- data/lib/graphql/schema/member/validates_input.rb +33 -0
- data/lib/graphql/schema/member.rb +11 -0
- data/lib/graphql/schema/middleware_chain.rb +1 -1
- data/lib/graphql/schema/mutation.rb +4 -0
- data/lib/graphql/schema/non_null.rb +37 -1
- data/lib/graphql/schema/object.rb +51 -38
- data/lib/graphql/schema/possible_types.rb +9 -4
- data/lib/graphql/schema/printer.rb +16 -35
- data/lib/graphql/schema/relay_classic_mutation.rb +40 -4
- data/lib/graphql/schema/resolver/has_payload_type.rb +34 -4
- data/lib/graphql/schema/resolver.rb +133 -79
- data/lib/graphql/schema/scalar.rb +43 -3
- data/lib/graphql/schema/subscription.rb +57 -21
- data/lib/graphql/schema/timeout.rb +29 -15
- data/lib/graphql/schema/timeout_middleware.rb +3 -1
- data/lib/graphql/schema/traversal.rb +2 -2
- data/lib/graphql/schema/type_expression.rb +21 -13
- data/lib/graphql/schema/type_membership.rb +19 -5
- data/lib/graphql/schema/union.rb +44 -3
- data/lib/graphql/schema/unique_within_type.rb +1 -2
- data/lib/graphql/schema/validation.rb +14 -4
- data/lib/graphql/schema/validator/allow_blank_validator.rb +29 -0
- data/lib/graphql/schema/validator/allow_null_validator.rb +26 -0
- data/lib/graphql/schema/validator/exclusion_validator.rb +33 -0
- data/lib/graphql/schema/validator/format_validator.rb +48 -0
- data/lib/graphql/schema/validator/inclusion_validator.rb +35 -0
- data/lib/graphql/schema/validator/length_validator.rb +59 -0
- data/lib/graphql/schema/validator/numericality_validator.rb +82 -0
- data/lib/graphql/schema/validator/required_validator.rb +82 -0
- data/lib/graphql/schema/validator.rb +171 -0
- data/lib/graphql/schema/warden.rb +193 -34
- data/lib/graphql/schema.rb +882 -247
- data/lib/graphql/static_validation/all_rules.rb +2 -0
- data/lib/graphql/static_validation/base_visitor.rb +17 -10
- data/lib/graphql/static_validation/definition_dependencies.rb +0 -1
- data/lib/graphql/static_validation/error.rb +3 -1
- data/lib/graphql/static_validation/literal_validator.rb +51 -26
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +45 -83
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +22 -6
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +35 -26
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +4 -2
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +1 -1
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +2 -2
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +4 -4
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +5 -5
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +94 -51
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +25 -4
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +2 -2
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +30 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +30 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +17 -0
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +26 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -2
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +9 -10
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +1 -1
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +12 -13
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +19 -14
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +5 -3
- data/lib/graphql/static_validation/type_stack.rb +2 -2
- data/lib/graphql/static_validation/validation_context.rb +13 -3
- data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
- data/lib/graphql/static_validation/validator.rb +43 -9
- data/lib/graphql/static_validation.rb +1 -0
- data/lib/graphql/string_encoding_error.rb +13 -3
- data/lib/graphql/string_type.rb +1 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +123 -22
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +81 -0
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +21 -0
- data/lib/graphql/subscriptions/event.rb +84 -30
- data/lib/graphql/subscriptions/instrumentation.rb +10 -6
- data/lib/graphql/subscriptions/serialize.rb +53 -6
- data/lib/graphql/subscriptions/subscription_root.rb +15 -5
- data/lib/graphql/subscriptions.rb +117 -49
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +8 -17
- data/lib/graphql/tracing/appoptics_tracing.rb +173 -0
- data/lib/graphql/tracing/appsignal_tracing.rb +23 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +32 -15
- data/lib/graphql/tracing/new_relic_tracing.rb +9 -12
- data/lib/graphql/tracing/notifications_tracing.rb +59 -0
- data/lib/graphql/tracing/platform_tracing.rb +66 -10
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +4 -1
- data/lib/graphql/tracing/prometheus_tracing.rb +8 -0
- data/lib/graphql/tracing/scout_tracing.rb +19 -0
- data/lib/graphql/tracing/skylight_tracing.rb +9 -1
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing.rb +15 -35
- data/lib/graphql/types/big_int.rb +5 -1
- data/lib/graphql/types/int.rb +10 -3
- data/lib/graphql/types/iso_8601_date.rb +16 -8
- data/lib/graphql/types/iso_8601_date_time.rb +32 -10
- data/lib/graphql/types/relay/base_connection.rb +6 -88
- data/lib/graphql/types/relay/base_edge.rb +2 -34
- data/lib/graphql/types/relay/connection_behaviors.rb +174 -0
- data/lib/graphql/types/relay/default_relay.rb +31 -0
- data/lib/graphql/types/relay/edge_behaviors.rb +64 -0
- data/lib/graphql/types/relay/has_node_field.rb +41 -0
- data/lib/graphql/types/relay/has_nodes_field.rb +41 -0
- data/lib/graphql/types/relay/node.rb +2 -4
- data/lib/graphql/types/relay/node_behaviors.rb +15 -0
- data/lib/graphql/types/relay/node_field.rb +3 -22
- data/lib/graphql/types/relay/nodes_field.rb +16 -18
- data/lib/graphql/types/relay/page_info.rb +2 -14
- data/lib/graphql/types/relay/page_info_behaviors.rb +25 -0
- data/lib/graphql/types/relay.rb +11 -3
- data/lib/graphql/types/string.rb +8 -2
- data/lib/graphql/unauthorized_error.rb +2 -2
- data/lib/graphql/union_type.rb +5 -25
- data/lib/graphql/unresolved_type_error.rb +2 -2
- data/lib/graphql/upgrader/member.rb +1 -0
- data/lib/graphql/upgrader/schema.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +87 -31
- data/readme.md +3 -6
- metadata +126 -124
- data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
- data/lib/graphql/literal_validation_error.rb +0 -6
- data/lib/graphql/types/relay/base_field.rb +0 -22
- data/lib/graphql/types/relay/base_interface.rb +0 -29
- data/lib/graphql/types/relay/base_object.rb +0 -26
|
@@ -39,11 +39,11 @@ module GraphQL
|
|
|
39
39
|
|
|
40
40
|
# Value equality
|
|
41
41
|
# @return [Boolean] True if `self` is equivalent to `other`
|
|
42
|
-
def
|
|
42
|
+
def ==(other)
|
|
43
43
|
return true if equal?(other)
|
|
44
|
-
other.
|
|
45
|
-
other.scalars
|
|
46
|
-
other.children
|
|
44
|
+
other.kind_of?(self.class) &&
|
|
45
|
+
other.scalars == self.scalars &&
|
|
46
|
+
other.children == self.children
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
NO_CHILDREN = [].freeze
|
|
@@ -65,9 +65,8 @@ module GraphQL
|
|
|
65
65
|
@query_string = nil
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
raise GraphQL::RequiredImplementationMissingError, "#{self.class.name}#visit_method shold return a symbol"
|
|
68
|
+
def children_method_name
|
|
69
|
+
self.class.children_method_name
|
|
71
70
|
end
|
|
72
71
|
|
|
73
72
|
def position
|
|
@@ -134,6 +133,8 @@ module GraphQL
|
|
|
134
133
|
end
|
|
135
134
|
|
|
136
135
|
class << self
|
|
136
|
+
# rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
|
|
137
|
+
|
|
137
138
|
# Add a default `#visit_method` and `#children_method_name` using the class name
|
|
138
139
|
def inherited(child_class)
|
|
139
140
|
super
|
|
@@ -147,9 +148,10 @@ module GraphQL
|
|
|
147
148
|
:on_#{name_underscored}
|
|
148
149
|
end
|
|
149
150
|
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
class << self
|
|
152
|
+
attr_accessor :children_method_name
|
|
152
153
|
end
|
|
154
|
+
self.children_method_name = :#{name_underscored}s
|
|
153
155
|
RUBY
|
|
154
156
|
end
|
|
155
157
|
|
|
@@ -161,7 +163,7 @@ module GraphQL
|
|
|
161
163
|
# - Add a persistent update method to add a child
|
|
162
164
|
# - Generate a `#children` method
|
|
163
165
|
def children_methods(children_of_type)
|
|
164
|
-
if @children_methods
|
|
166
|
+
if defined?(@children_methods)
|
|
165
167
|
raise "Can't re-call .children_methods for #{self} (already have: #{@children_methods})"
|
|
166
168
|
else
|
|
167
169
|
@children_methods = children_of_type
|
|
@@ -197,14 +199,27 @@ module GraphQL
|
|
|
197
199
|
else
|
|
198
200
|
module_eval <<-RUBY, __FILE__, __LINE__
|
|
199
201
|
def children
|
|
200
|
-
@children ||=
|
|
202
|
+
@children ||= begin
|
|
203
|
+
if #{children_of_type.keys.map { |k| "@#{k}.any?" }.join(" || ")}
|
|
204
|
+
new_children = []
|
|
205
|
+
#{children_of_type.keys.map { |k| "new_children.concat(@#{k})" }.join("; ")}
|
|
206
|
+
new_children.freeze
|
|
207
|
+
new_children
|
|
208
|
+
else
|
|
209
|
+
NO_CHILDREN
|
|
210
|
+
end
|
|
211
|
+
end
|
|
201
212
|
end
|
|
202
213
|
RUBY
|
|
203
214
|
end
|
|
204
215
|
end
|
|
205
216
|
|
|
206
217
|
if defined?(@scalar_methods)
|
|
207
|
-
|
|
218
|
+
if !method_defined?(:initialize_node)
|
|
219
|
+
generate_initialize_node
|
|
220
|
+
else
|
|
221
|
+
# This method was defined manually
|
|
222
|
+
end
|
|
208
223
|
else
|
|
209
224
|
raise "Can't generate_initialize_node because scalar_methods wasn't called; call it before children_methods"
|
|
210
225
|
end
|
|
@@ -214,7 +229,7 @@ module GraphQL
|
|
|
214
229
|
# - Add reader methods
|
|
215
230
|
# - Add a `#scalars` method
|
|
216
231
|
def scalar_methods(*method_names)
|
|
217
|
-
if @scalar_methods
|
|
232
|
+
if defined?(@scalar_methods)
|
|
218
233
|
raise "Can't re-call .scalar_methods for #{self} (already have: #{@scalar_methods})"
|
|
219
234
|
else
|
|
220
235
|
@scalar_methods = method_names
|
|
@@ -251,7 +266,7 @@ module GraphQL
|
|
|
251
266
|
return
|
|
252
267
|
else
|
|
253
268
|
arguments = scalar_method_names.map { |m| "#{m}: nil"} +
|
|
254
|
-
@children_methods.keys.map { |m| "#{m}:
|
|
269
|
+
@children_methods.keys.map { |m| "#{m}: NO_CHILDREN" }
|
|
255
270
|
|
|
256
271
|
assignments = scalar_method_names.map { |m| "@#{m} = #{m}"} +
|
|
257
272
|
@children_methods.keys.map { |m| "@#{m} = #{m}.freeze" }
|
|
@@ -263,6 +278,7 @@ module GraphQL
|
|
|
263
278
|
RUBY
|
|
264
279
|
end
|
|
265
280
|
end
|
|
281
|
+
# rubocop:enable Development/NoEvalCop
|
|
266
282
|
end
|
|
267
283
|
end
|
|
268
284
|
|
|
@@ -305,7 +321,7 @@ module GraphQL
|
|
|
305
321
|
class DirectiveDefinition < AbstractNode
|
|
306
322
|
include DefinitionNode
|
|
307
323
|
attr_reader :description
|
|
308
|
-
scalar_methods :name
|
|
324
|
+
scalar_methods :name, :repeatable
|
|
309
325
|
children_methods(
|
|
310
326
|
locations: Nodes::DirectiveLocation,
|
|
311
327
|
arguments: Nodes::Argument,
|
|
@@ -328,7 +344,7 @@ module GraphQL
|
|
|
328
344
|
# end
|
|
329
345
|
# end
|
|
330
346
|
#
|
|
331
|
-
# document.to_query_string(printer:
|
|
347
|
+
# document.to_query_string(printer: VariableScrubber.new)
|
|
332
348
|
#
|
|
333
349
|
class Document < AbstractNode
|
|
334
350
|
scalar_methods false
|
|
@@ -373,19 +389,11 @@ module GraphQL
|
|
|
373
389
|
end
|
|
374
390
|
|
|
375
391
|
# Override this because default is `:fields`
|
|
376
|
-
|
|
377
|
-
:selections
|
|
378
|
-
end
|
|
392
|
+
self.children_method_name = :selections
|
|
379
393
|
end
|
|
380
394
|
|
|
381
395
|
# A reusable fragment, defined at document-level.
|
|
382
396
|
class FragmentDefinition < AbstractNode
|
|
383
|
-
scalar_methods :name, :type
|
|
384
|
-
children_methods({
|
|
385
|
-
selections: GraphQL::Language::Nodes::Field,
|
|
386
|
-
directives: GraphQL::Language::Nodes::Directive,
|
|
387
|
-
})
|
|
388
|
-
|
|
389
397
|
# @!attribute name
|
|
390
398
|
# @return [String] the identifier for this fragment, which may be applied with `...#{name}`
|
|
391
399
|
|
|
@@ -398,9 +406,13 @@ module GraphQL
|
|
|
398
406
|
@selections = selections
|
|
399
407
|
end
|
|
400
408
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
409
|
+
scalar_methods :name, :type
|
|
410
|
+
children_methods({
|
|
411
|
+
selections: GraphQL::Language::Nodes::Field,
|
|
412
|
+
directives: GraphQL::Language::Nodes::Directive,
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
self.children_method_name = :definitions
|
|
404
416
|
end
|
|
405
417
|
|
|
406
418
|
# Application of a named fragment in a selection
|
|
@@ -408,9 +420,7 @@ module GraphQL
|
|
|
408
420
|
scalar_methods :name
|
|
409
421
|
children_methods(directives: GraphQL::Language::Nodes::Directive)
|
|
410
422
|
|
|
411
|
-
|
|
412
|
-
:selections
|
|
413
|
-
end
|
|
423
|
+
self.children_method_name = :selections
|
|
414
424
|
|
|
415
425
|
# @!attribute name
|
|
416
426
|
# @return [String] The identifier of the fragment to apply, corresponds with {FragmentDefinition#name}
|
|
@@ -424,9 +434,7 @@ module GraphQL
|
|
|
424
434
|
directives: GraphQL::Language::Nodes::Directive,
|
|
425
435
|
})
|
|
426
436
|
|
|
427
|
-
|
|
428
|
-
:selections
|
|
429
|
-
end
|
|
437
|
+
self.children_method_name = :selections
|
|
430
438
|
|
|
431
439
|
# @!attribute type
|
|
432
440
|
# @return [String, nil] Name of the type this fragment applies to, or `nil` if this fragment applies to any type
|
|
@@ -449,9 +457,7 @@ module GraphQL
|
|
|
449
457
|
end
|
|
450
458
|
end
|
|
451
459
|
|
|
452
|
-
|
|
453
|
-
:value
|
|
454
|
-
end
|
|
460
|
+
self.children_method_name = :value
|
|
455
461
|
|
|
456
462
|
private
|
|
457
463
|
|
|
@@ -473,7 +479,6 @@ module GraphQL
|
|
|
473
479
|
end
|
|
474
480
|
end
|
|
475
481
|
|
|
476
|
-
|
|
477
482
|
# A list type definition, denoted with `[...]` (used for variable type definitions)
|
|
478
483
|
class ListType < WrapperType
|
|
479
484
|
end
|
|
@@ -494,6 +499,8 @@ module GraphQL
|
|
|
494
499
|
|
|
495
500
|
# @!attribute name
|
|
496
501
|
# @return [String] The identifier for this variable, _without_ `$`
|
|
502
|
+
|
|
503
|
+
self.children_method_name = :variables
|
|
497
504
|
end
|
|
498
505
|
|
|
499
506
|
# A query, mutation or subscription.
|
|
@@ -508,7 +515,7 @@ module GraphQL
|
|
|
508
515
|
})
|
|
509
516
|
|
|
510
517
|
# @!attribute variables
|
|
511
|
-
# @return [Array<VariableDefinition>] Variable definitions for this operation
|
|
518
|
+
# @return [Array<VariableDefinition>] Variable $definitions for this operation
|
|
512
519
|
|
|
513
520
|
# @!attribute selections
|
|
514
521
|
# @return [Array<Field>] Root-level fields on this operation
|
|
@@ -519,9 +526,7 @@ module GraphQL
|
|
|
519
526
|
# @!attribute name
|
|
520
527
|
# @return [String, nil] The name for this operation, or `nil` if unnamed
|
|
521
528
|
|
|
522
|
-
|
|
523
|
-
:definitions
|
|
524
|
-
end
|
|
529
|
+
self.children_method_name = :definitions
|
|
525
530
|
end
|
|
526
531
|
|
|
527
532
|
# A type name, used for variable definitions
|
|
@@ -530,6 +535,7 @@ module GraphQL
|
|
|
530
535
|
|
|
531
536
|
# Usage of a variable in a query. Name does _not_ include `$`.
|
|
532
537
|
class VariableIdentifier < NameOnlyNode
|
|
538
|
+
self.children_method_name = :value
|
|
533
539
|
end
|
|
534
540
|
|
|
535
541
|
class SchemaDefinition < AbstractNode
|
|
@@ -538,9 +544,7 @@ module GraphQL
|
|
|
538
544
|
children_methods({
|
|
539
545
|
directives: GraphQL::Language::Nodes::Directive,
|
|
540
546
|
})
|
|
541
|
-
|
|
542
|
-
:definitions
|
|
543
|
-
end
|
|
547
|
+
self.children_method_name = :definitions
|
|
544
548
|
end
|
|
545
549
|
|
|
546
550
|
class SchemaExtension < AbstractNode
|
|
@@ -548,9 +552,7 @@ module GraphQL
|
|
|
548
552
|
children_methods({
|
|
549
553
|
directives: GraphQL::Language::Nodes::Directive,
|
|
550
554
|
})
|
|
551
|
-
|
|
552
|
-
:definitions
|
|
553
|
-
end
|
|
555
|
+
self.children_method_name = :definitions
|
|
554
556
|
end
|
|
555
557
|
|
|
556
558
|
class ScalarTypeDefinition < AbstractNode
|
|
@@ -560,9 +562,7 @@ module GraphQL
|
|
|
560
562
|
children_methods({
|
|
561
563
|
directives: GraphQL::Language::Nodes::Directive,
|
|
562
564
|
})
|
|
563
|
-
|
|
564
|
-
:definitions
|
|
565
|
-
end
|
|
565
|
+
self.children_method_name = :definitions
|
|
566
566
|
end
|
|
567
567
|
|
|
568
568
|
class ScalarTypeExtension < AbstractNode
|
|
@@ -570,9 +570,7 @@ module GraphQL
|
|
|
570
570
|
children_methods({
|
|
571
571
|
directives: GraphQL::Language::Nodes::Directive,
|
|
572
572
|
})
|
|
573
|
-
|
|
574
|
-
:definitions
|
|
575
|
-
end
|
|
573
|
+
self.children_method_name = :definitions
|
|
576
574
|
end
|
|
577
575
|
|
|
578
576
|
class InputValueDefinition < AbstractNode
|
|
@@ -582,9 +580,7 @@ module GraphQL
|
|
|
582
580
|
children_methods({
|
|
583
581
|
directives: GraphQL::Language::Nodes::Directive,
|
|
584
582
|
})
|
|
585
|
-
|
|
586
|
-
:fields
|
|
587
|
-
end
|
|
583
|
+
self.children_method_name = :fields
|
|
588
584
|
end
|
|
589
585
|
|
|
590
586
|
class FieldDefinition < AbstractNode
|
|
@@ -595,9 +591,7 @@ module GraphQL
|
|
|
595
591
|
directives: GraphQL::Language::Nodes::Directive,
|
|
596
592
|
arguments: GraphQL::Language::Nodes::InputValueDefinition,
|
|
597
593
|
})
|
|
598
|
-
|
|
599
|
-
:fields
|
|
600
|
-
end
|
|
594
|
+
self.children_method_name = :fields
|
|
601
595
|
|
|
602
596
|
# this is so that `children_method_name` of `InputValueDefinition` works properly
|
|
603
597
|
# with `#replace_child`
|
|
@@ -618,9 +612,7 @@ module GraphQL
|
|
|
618
612
|
directives: GraphQL::Language::Nodes::Directive,
|
|
619
613
|
fields: GraphQL::Language::Nodes::FieldDefinition,
|
|
620
614
|
})
|
|
621
|
-
|
|
622
|
-
:definitions
|
|
623
|
-
end
|
|
615
|
+
self.children_method_name = :definitions
|
|
624
616
|
end
|
|
625
617
|
|
|
626
618
|
class ObjectTypeExtension < AbstractNode
|
|
@@ -629,9 +621,7 @@ module GraphQL
|
|
|
629
621
|
directives: GraphQL::Language::Nodes::Directive,
|
|
630
622
|
fields: GraphQL::Language::Nodes::FieldDefinition,
|
|
631
623
|
})
|
|
632
|
-
|
|
633
|
-
:definitions
|
|
634
|
-
end
|
|
624
|
+
self.children_method_name = :definitions
|
|
635
625
|
end
|
|
636
626
|
|
|
637
627
|
class InterfaceTypeDefinition < AbstractNode
|
|
@@ -639,23 +629,21 @@ module GraphQL
|
|
|
639
629
|
attr_reader :description
|
|
640
630
|
scalar_methods :name
|
|
641
631
|
children_methods({
|
|
632
|
+
interfaces: GraphQL::Language::Nodes::TypeName,
|
|
642
633
|
directives: GraphQL::Language::Nodes::Directive,
|
|
643
634
|
fields: GraphQL::Language::Nodes::FieldDefinition,
|
|
644
635
|
})
|
|
645
|
-
|
|
646
|
-
:definitions
|
|
647
|
-
end
|
|
636
|
+
self.children_method_name = :definitions
|
|
648
637
|
end
|
|
649
638
|
|
|
650
639
|
class InterfaceTypeExtension < AbstractNode
|
|
651
640
|
scalar_methods :name
|
|
652
641
|
children_methods({
|
|
642
|
+
interfaces: GraphQL::Language::Nodes::TypeName,
|
|
653
643
|
directives: GraphQL::Language::Nodes::Directive,
|
|
654
644
|
fields: GraphQL::Language::Nodes::FieldDefinition,
|
|
655
645
|
})
|
|
656
|
-
|
|
657
|
-
:definitions
|
|
658
|
-
end
|
|
646
|
+
self.children_method_name = :definitions
|
|
659
647
|
end
|
|
660
648
|
|
|
661
649
|
class UnionTypeDefinition < AbstractNode
|
|
@@ -665,9 +653,7 @@ module GraphQL
|
|
|
665
653
|
children_methods({
|
|
666
654
|
directives: GraphQL::Language::Nodes::Directive,
|
|
667
655
|
})
|
|
668
|
-
|
|
669
|
-
:definitions
|
|
670
|
-
end
|
|
656
|
+
self.children_method_name = :definitions
|
|
671
657
|
end
|
|
672
658
|
|
|
673
659
|
class UnionTypeExtension < AbstractNode
|
|
@@ -676,9 +662,7 @@ module GraphQL
|
|
|
676
662
|
children_methods({
|
|
677
663
|
directives: GraphQL::Language::Nodes::Directive,
|
|
678
664
|
})
|
|
679
|
-
|
|
680
|
-
:definitions
|
|
681
|
-
end
|
|
665
|
+
self.children_method_name = :definitions
|
|
682
666
|
end
|
|
683
667
|
|
|
684
668
|
class EnumValueDefinition < AbstractNode
|
|
@@ -688,9 +672,7 @@ module GraphQL
|
|
|
688
672
|
children_methods({
|
|
689
673
|
directives: GraphQL::Language::Nodes::Directive,
|
|
690
674
|
})
|
|
691
|
-
|
|
692
|
-
:values
|
|
693
|
-
end
|
|
675
|
+
self.children_method_name = :values
|
|
694
676
|
end
|
|
695
677
|
|
|
696
678
|
class EnumTypeDefinition < AbstractNode
|
|
@@ -701,9 +683,7 @@ module GraphQL
|
|
|
701
683
|
directives: GraphQL::Language::Nodes::Directive,
|
|
702
684
|
values: GraphQL::Language::Nodes::EnumValueDefinition,
|
|
703
685
|
})
|
|
704
|
-
|
|
705
|
-
:definitions
|
|
706
|
-
end
|
|
686
|
+
self.children_method_name = :definitions
|
|
707
687
|
end
|
|
708
688
|
|
|
709
689
|
class EnumTypeExtension < AbstractNode
|
|
@@ -712,9 +692,7 @@ module GraphQL
|
|
|
712
692
|
directives: GraphQL::Language::Nodes::Directive,
|
|
713
693
|
values: GraphQL::Language::Nodes::EnumValueDefinition,
|
|
714
694
|
})
|
|
715
|
-
|
|
716
|
-
:definitions
|
|
717
|
-
end
|
|
695
|
+
self.children_method_name = :definitions
|
|
718
696
|
end
|
|
719
697
|
|
|
720
698
|
class InputObjectTypeDefinition < AbstractNode
|
|
@@ -725,9 +703,7 @@ module GraphQL
|
|
|
725
703
|
directives: GraphQL::Language::Nodes::Directive,
|
|
726
704
|
fields: GraphQL::Language::Nodes::InputValueDefinition,
|
|
727
705
|
})
|
|
728
|
-
|
|
729
|
-
:definitions
|
|
730
|
-
end
|
|
706
|
+
self.children_method_name = :definitions
|
|
731
707
|
end
|
|
732
708
|
|
|
733
709
|
class InputObjectTypeExtension < AbstractNode
|
|
@@ -736,9 +712,7 @@ module GraphQL
|
|
|
736
712
|
directives: GraphQL::Language::Nodes::Directive,
|
|
737
713
|
fields: GraphQL::Language::Nodes::InputValueDefinition,
|
|
738
714
|
})
|
|
739
|
-
|
|
740
|
-
:definitions
|
|
741
|
-
end
|
|
715
|
+
self.children_method_name = :definitions
|
|
742
716
|
end
|
|
743
717
|
end
|
|
744
718
|
end
|