graphql 1.9.21 → 2.0.0
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.
Potentially problematic release.
This version of graphql might be problematic. Click here for more details.
- 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/ast/field_usage.rb +29 -2
- data/lib/graphql/analysis/ast/query_complexity.rb +175 -68
- data/lib/graphql/analysis/ast/query_depth.rb +0 -1
- data/lib/graphql/analysis/ast/visitor.rb +17 -8
- data/lib/graphql/analysis/ast.rb +14 -14
- data/lib/graphql/analysis.rb +0 -7
- data/lib/graphql/backtrace/inspect_result.rb +0 -1
- data/lib/graphql/backtrace/table.rb +37 -16
- data/lib/graphql/backtrace/traced_error.rb +0 -1
- data/lib/graphql/backtrace/tracer.rb +39 -9
- data/lib/graphql/backtrace.rb +20 -17
- 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/deprecation.rb +9 -0
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/directive_checks.rb +2 -2
- data/lib/graphql/execution/errors.rb +108 -14
- 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 +715 -387
- data/lib/graphql/execution/interpreter.rb +32 -31
- 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 +32 -114
- data/lib/graphql/execution/multiplex.rb +60 -92
- data/lib/graphql/execution.rb +11 -3
- data/lib/graphql/filter.rb +1 -1
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +18 -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 +11 -5
- data/lib/graphql/introspection/dynamic_fields.rb +3 -8
- data/lib/graphql/introspection/entry_points.rb +5 -18
- 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 +10 -10
- 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 +99 -63
- data/lib/graphql/language/lexer.rb +53 -27
- data/lib/graphql/language/lexer.rl +5 -3
- data/lib/graphql/language/nodes.rb +64 -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/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 +134 -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/context.rb +51 -190
- data/lib/graphql/query/fingerprint.rb +26 -0
- data/lib/graphql/query/input_validation_result.rb +23 -6
- data/lib/graphql/query/literal_input.rb +26 -11
- data/lib/graphql/query/null_context.rb +24 -8
- data/lib/graphql/query/validation_pipeline.rb +12 -38
- data/lib/graphql/query/variable_validation_error.rb +2 -2
- data/lib/graphql/query/variables.rb +26 -9
- data/lib/graphql/query.rb +62 -32
- data/lib/graphql/railtie.rb +6 -102
- data/lib/graphql/rake_task/validate.rb +3 -0
- data/lib/graphql/rake_task.rb +12 -9
- data/lib/graphql/relay/range_add.rb +23 -9
- data/lib/graphql/relay.rb +0 -15
- 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/schema/addition.rb +240 -0
- data/lib/graphql/schema/argument.rb +262 -28
- 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 +319 -220
- data/lib/graphql/schema/built_in_types.rb +5 -5
- 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 +117 -14
- data/lib/graphql/schema/enum.rb +115 -22
- data/lib/graphql/schema/enum_value.rb +16 -21
- 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 +376 -291
- 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 +147 -60
- data/lib/graphql/schema/interface.rb +28 -43
- data/lib/graphql/schema/introspection_system.rb +101 -38
- data/lib/graphql/schema/late_bound_type.rb +3 -2
- data/lib/graphql/schema/list.rb +46 -3
- data/lib/graphql/schema/loader.rb +144 -102
- data/lib/graphql/schema/member/base_dsl_methods.rb +33 -32
- data/lib/graphql/schema/member/build_type.rb +23 -14
- data/lib/graphql/schema/member/has_arguments.rb +212 -23
- 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 +99 -34
- data/lib/graphql/schema/member/has_interfaces.rb +88 -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/type_system_helpers.rb +3 -3
- data/lib/graphql/schema/member/validates_input.rb +33 -0
- data/lib/graphql/schema/member.rb +11 -6
- data/lib/graphql/schema/mutation.rb +4 -9
- data/lib/graphql/schema/non_null.rb +34 -4
- data/lib/graphql/schema/object.rb +38 -65
- data/lib/graphql/schema/printer.rb +16 -35
- data/lib/graphql/schema/relay_classic_mutation.rb +57 -32
- 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 +40 -15
- data/lib/graphql/schema/subscription.rb +57 -21
- data/lib/graphql/schema/timeout.rb +29 -15
- data/lib/graphql/schema/type_expression.rb +21 -13
- data/lib/graphql/schema/type_membership.rb +19 -5
- data/lib/graphql/schema/union.rb +39 -14
- data/lib/graphql/schema/unique_within_type.rb +1 -2
- 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 +182 -32
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +687 -891
- data/lib/graphql/static_validation/all_rules.rb +2 -0
- data/lib/graphql/static_validation/base_visitor.rb +21 -31
- 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 +14 -14
- 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 +31 -19
- data/lib/graphql/static_validation.rb +1 -2
- data/lib/graphql/string_encoding_error.rb +13 -3
- 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 +58 -0
- data/lib/graphql/subscriptions/event.rb +85 -31
- data/lib/graphql/subscriptions/instrumentation.rb +0 -47
- data/lib/graphql/subscriptions/serialize.rb +53 -6
- data/lib/graphql/subscriptions.rb +111 -52
- 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 +14 -1
- 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 +57 -29
- 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/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing.rb +15 -36
- 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 +170 -0
- data/lib/graphql/types/relay/default_relay.rb +21 -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 +19 -0
- 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 -5
- data/lib/graphql/types/string.rb +8 -2
- data/lib/graphql/unauthorized_error.rb +2 -2
- data/lib/graphql/unresolved_type_error.rb +2 -2
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +41 -58
- data/readme.md +3 -6
- metadata +97 -231
- data/lib/graphql/analysis/analyze_query.rb +0 -91
- 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 -159
- data/lib/graphql/authorization.rb +0 -82
- data/lib/graphql/backwards_compatibility.rb +0 -60
- data/lib/graphql/base_type.rb +0 -226
- 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 -435
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
- data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -213
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -91
- data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -264
- data/lib/graphql/compatibility/schema_parser_specification.rb +0 -680
- 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 -311
- 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 -42
- data/lib/graphql/directive/deprecated_directive.rb +0 -13
- data/lib/graphql/directive/include_directive.rb +0 -2
- data/lib/graphql/directive/skip_directive.rb +0 -2
- data/lib/graphql/directive.rb +0 -104
- data/lib/graphql/enum_type.rb +0 -193
- data/lib/graphql/execution/execute.rb +0 -326
- data/lib/graphql/execution/flatten.rb +0 -40
- data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
- data/lib/graphql/execution/typecast.rb +0 -50
- data/lib/graphql/field/resolve.rb +0 -59
- data/lib/graphql/field.rb +0 -330
- data/lib/graphql/float_type.rb +0 -2
- data/lib/graphql/function.rb +0 -153
- data/lib/graphql/id_type.rb +0 -2
- data/lib/graphql/input_object_type.rb +0 -154
- data/lib/graphql/int_type.rb +0 -2
- data/lib/graphql/interface_type.rb +0 -86
- 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/list_type.rb +0 -80
- data/lib/graphql/literal_validation_error.rb +0 -6
- data/lib/graphql/non_null_type.rb +0 -81
- data/lib/graphql/object_type.rb +0 -141
- data/lib/graphql/query/arguments.rb +0 -187
- data/lib/graphql/query/arguments_cache.rb +0 -25
- data/lib/graphql/query/executor.rb +0 -53
- 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 -39
- data/lib/graphql/relay/array_connection.rb +0 -85
- data/lib/graphql/relay/base_connection.rb +0 -172
- 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 -40
- data/lib/graphql/relay/edge.rb +0 -27
- data/lib/graphql/relay/edge_type.rb +0 -18
- data/lib/graphql/relay/edges_instrumentation.rb +0 -40
- data/lib/graphql/relay/global_id_resolve.rb +0 -18
- 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 -190
- data/lib/graphql/relay/node.rb +0 -36
- data/lib/graphql/relay/page_info.rb +0 -7
- data/lib/graphql/relay/relation_connection.rb +0 -190
- data/lib/graphql/relay/type_extensions.rb +0 -30
- data/lib/graphql/scalar_type.rb +0 -133
- 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 -15
- data/lib/graphql/schema/member/accepts_definition.rb +0 -152
- data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -26
- data/lib/graphql/schema/member/instrumentation.rb +0 -132
- data/lib/graphql/schema/middleware_chain.rb +0 -82
- data/lib/graphql/schema/possible_types.rb +0 -39
- data/lib/graphql/schema/rescue_middleware.rb +0 -60
- data/lib/graphql/schema/timeout_middleware.rb +0 -86
- data/lib/graphql/schema/traversal.rb +0 -228
- data/lib/graphql/schema/validation.rb +0 -303
- 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 -74
- data/lib/graphql/tracing/skylight_tracing.rb +0 -62
- 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
- data/lib/graphql/types/relay/node_field.rb +0 -43
- data/lib/graphql/types/relay/nodes_field.rb +0 -45
- data/lib/graphql/union_type.rb +0 -135
- data/lib/graphql/upgrader/member.rb +0 -936
- data/lib/graphql/upgrader/schema.rb +0 -37
@@ -1,154 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
# {InputObjectType}s are key-value inputs for fields.
|
4
|
-
#
|
5
|
-
# Input objects have _arguments_ which are identical to {GraphQL::Field} arguments.
|
6
|
-
# They map names to types and support default values.
|
7
|
-
# Their input types can be any input types, including {InputObjectType}s.
|
8
|
-
#
|
9
|
-
# @example An input type with name and number
|
10
|
-
# PlayerInput = GraphQL::InputObjectType.define do
|
11
|
-
# name("Player")
|
12
|
-
# argument :name, !types.String
|
13
|
-
# argument :number, !types.Int
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# In a `resolve` function, you can access the values by making nested lookups on `args`.
|
17
|
-
#
|
18
|
-
# @example Accessing input values in a resolve function
|
19
|
-
# resolve ->(obj, args, ctx) {
|
20
|
-
# args[:player][:name] # => "Tony Gwynn"
|
21
|
-
# args[:player][:number] # => 19
|
22
|
-
# args[:player].to_h # { "name" => "Tony Gwynn", "number" => 19 }
|
23
|
-
# # ...
|
24
|
-
# }
|
25
|
-
#
|
26
|
-
class InputObjectType < GraphQL::BaseType
|
27
|
-
accepts_definitions(
|
28
|
-
:arguments, :mutation,
|
29
|
-
input_field: GraphQL::Define::AssignArgument,
|
30
|
-
argument: GraphQL::Define::AssignArgument
|
31
|
-
)
|
32
|
-
|
33
|
-
attr_accessor :mutation, :arguments, :arguments_class
|
34
|
-
ensure_defined(:mutation, :arguments, :input_fields)
|
35
|
-
alias :input_fields :arguments
|
36
|
-
|
37
|
-
# @!attribute mutation
|
38
|
-
# @return [GraphQL::Relay::Mutation, nil] The mutation this field was derived from, if it was derived from a mutation
|
39
|
-
|
40
|
-
# @!attribute arguments
|
41
|
-
# @return [Hash<String => GraphQL::Argument>] Map String argument names to their {GraphQL::Argument} implementations
|
42
|
-
|
43
|
-
|
44
|
-
def initialize
|
45
|
-
super
|
46
|
-
@arguments = {}
|
47
|
-
end
|
48
|
-
|
49
|
-
def initialize_copy(other)
|
50
|
-
super
|
51
|
-
@arguments = other.arguments.dup
|
52
|
-
end
|
53
|
-
|
54
|
-
def kind
|
55
|
-
GraphQL::TypeKinds::INPUT_OBJECT
|
56
|
-
end
|
57
|
-
|
58
|
-
def coerce_result(value, ctx = nil)
|
59
|
-
if ctx.nil?
|
60
|
-
warn_deprecated_coerce("coerce_isolated_result")
|
61
|
-
ctx = GraphQL::Query::NullContext
|
62
|
-
end
|
63
|
-
|
64
|
-
# Allow the application to provide values as :symbols, and convert them to the strings
|
65
|
-
value = value.reduce({}) { |memo, (k, v)| memo[k.to_s] = v; memo }
|
66
|
-
|
67
|
-
result = {}
|
68
|
-
|
69
|
-
arguments.each do |input_key, input_field_defn|
|
70
|
-
input_value = value[input_key]
|
71
|
-
if value.key?(input_key)
|
72
|
-
result[input_key] = if input_value.nil?
|
73
|
-
nil
|
74
|
-
else
|
75
|
-
input_field_defn.type.coerce_result(input_value, ctx)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
result
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
def coerce_non_null_input(value, ctx)
|
86
|
-
input_values = {}
|
87
|
-
defaults_used = Set.new
|
88
|
-
|
89
|
-
arguments.each do |input_key, input_field_defn|
|
90
|
-
field_value = value[input_key]
|
91
|
-
|
92
|
-
if value.key?(input_key)
|
93
|
-
coerced_value = input_field_defn.type.coerce_input(field_value, ctx)
|
94
|
-
input_values[input_key] = input_field_defn.prepare(coerced_value, ctx)
|
95
|
-
elsif input_field_defn.default_value?
|
96
|
-
coerced_value = input_field_defn.type.coerce_input(input_field_defn.default_value, ctx)
|
97
|
-
input_values[input_key] = coerced_value
|
98
|
-
defaults_used << input_key
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
result = arguments_class.new(input_values, context: ctx, defaults_used: defaults_used)
|
103
|
-
result.prepare
|
104
|
-
end
|
105
|
-
|
106
|
-
# @api private
|
107
|
-
INVALID_OBJECT_MESSAGE = "Expected %{object} to be a key, value object responding to `to_h` or `to_unsafe_h`."
|
108
|
-
|
109
|
-
def validate_non_null_input(input, ctx)
|
110
|
-
warden = ctx.warden
|
111
|
-
result = GraphQL::Query::InputValidationResult.new
|
112
|
-
|
113
|
-
if input.is_a?(Array)
|
114
|
-
result.add_problem(INVALID_OBJECT_MESSAGE % { object: JSON.generate(input, quirks_mode: true) })
|
115
|
-
return result
|
116
|
-
end
|
117
|
-
|
118
|
-
# We're not actually _using_ the coerced result, we're just
|
119
|
-
# using these methods to make sure that the object will
|
120
|
-
# behave like a hash below, when we call `each` on it.
|
121
|
-
begin
|
122
|
-
input.to_h
|
123
|
-
rescue
|
124
|
-
begin
|
125
|
-
# Handle ActionController::Parameters:
|
126
|
-
input.to_unsafe_h
|
127
|
-
rescue
|
128
|
-
# We're not sure it'll act like a hash, so reject it:
|
129
|
-
result.add_problem(INVALID_OBJECT_MESSAGE % { object: JSON.generate(input, quirks_mode: true) })
|
130
|
-
return result
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
visible_arguments_map = warden.arguments(self).reduce({}) { |m, f| m[f.name] = f; m}
|
135
|
-
|
136
|
-
# Items in the input that are unexpected
|
137
|
-
input.each do |name, value|
|
138
|
-
if visible_arguments_map[name].nil?
|
139
|
-
result.add_problem("Field is not defined on #{self.name}", [name])
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
# Items in the input that are expected, but have invalid values
|
144
|
-
visible_arguments_map.map do |name, field|
|
145
|
-
field_result = field.type.validate_input(input[name], ctx)
|
146
|
-
if !field_result.valid?
|
147
|
-
result.merge_result!(name, field_result)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
result
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
data/lib/graphql/int_type.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
# An Interface contains a collection of types which implement some of the same fields.
|
4
|
-
#
|
5
|
-
# Interfaces can have fields, defined with `field`, just like an object type.
|
6
|
-
#
|
7
|
-
# Objects which implement this field _inherit_ field definitions from the interface.
|
8
|
-
# An object type can override the inherited definition by redefining that field.
|
9
|
-
#
|
10
|
-
# @example An interface with three fields
|
11
|
-
# DeviceInterface = GraphQL::InterfaceType.define do
|
12
|
-
# name("Device")
|
13
|
-
# description("Hardware devices for computing")
|
14
|
-
#
|
15
|
-
# field :ram, types.String
|
16
|
-
# field :processor, ProcessorType
|
17
|
-
# field :release_year, types.Int
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
# @example Implementing an interface with an object type
|
21
|
-
# Laptoptype = GraphQL::ObjectType.define do
|
22
|
-
# interfaces [DeviceInterface]
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
class InterfaceType < GraphQL::BaseType
|
26
|
-
accepts_definitions :fields, :orphan_types, :resolve_type, field: GraphQL::Define::AssignObjectField
|
27
|
-
|
28
|
-
attr_accessor :fields, :orphan_types, :resolve_type_proc
|
29
|
-
ensure_defined :fields, :orphan_types, :resolve_type_proc, :resolve_type
|
30
|
-
|
31
|
-
def initialize
|
32
|
-
super
|
33
|
-
@fields = {}
|
34
|
-
@orphan_types = []
|
35
|
-
@resolve_type_proc = nil
|
36
|
-
end
|
37
|
-
|
38
|
-
def initialize_copy(other)
|
39
|
-
super
|
40
|
-
@fields = other.fields.dup
|
41
|
-
@orphan_types = other.orphan_types.dup
|
42
|
-
end
|
43
|
-
|
44
|
-
def kind
|
45
|
-
GraphQL::TypeKinds::INTERFACE
|
46
|
-
end
|
47
|
-
|
48
|
-
def resolve_type(value, ctx)
|
49
|
-
ctx.query.resolve_type(self, value)
|
50
|
-
end
|
51
|
-
|
52
|
-
def resolve_type=(resolve_type_callable)
|
53
|
-
@resolve_type_proc = resolve_type_callable
|
54
|
-
end
|
55
|
-
|
56
|
-
# @return [GraphQL::Field] The defined field for `field_name`
|
57
|
-
def get_field(field_name)
|
58
|
-
fields[field_name]
|
59
|
-
end
|
60
|
-
|
61
|
-
# These fields don't have instrumenation applied
|
62
|
-
# @see [Schema#get_fields] Get fields with instrumentation
|
63
|
-
# @return [Array<GraphQL::Field>] All fields on this type
|
64
|
-
def all_fields
|
65
|
-
fields.values
|
66
|
-
end
|
67
|
-
|
68
|
-
# Get a possible type of this {InterfaceType} by type name
|
69
|
-
# @param type_name [String]
|
70
|
-
# @param ctx [GraphQL::Query::Context] The context for the current query
|
71
|
-
# @return [GraphQL::ObjectType, nil] The type named `type_name` if it exists and implements this {InterfaceType}, (else `nil`)
|
72
|
-
def get_possible_type(type_name, ctx)
|
73
|
-
type = ctx.query.get_type(type_name)
|
74
|
-
type if type && ctx.query.schema.possible_types(self).include?(type)
|
75
|
-
end
|
76
|
-
|
77
|
-
# Check if a type is a possible type of this {InterfaceType}
|
78
|
-
# @param type [String, GraphQL::BaseType] Name of the type or a type definition
|
79
|
-
# @param ctx [GraphQL::Query::Context] The context for the current query
|
80
|
-
# @return [Boolean] True if the `type` exists and is a member of this {InterfaceType}, (else `nil`)
|
81
|
-
def possible_type?(type, ctx)
|
82
|
-
type_name = type.is_a?(String) ? type : type.graphql_name
|
83
|
-
!get_possible_type(type_name, ctx).nil?
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module InternalRepresentation
|
4
|
-
class Document
|
5
|
-
# @return [Hash<String, Node>] Operation Nodes of this query
|
6
|
-
attr_reader :operation_definitions
|
7
|
-
|
8
|
-
# @return [Hash<String, Node>] Fragment definition Nodes of this query
|
9
|
-
attr_reader :fragment_definitions
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@operation_definitions = {}
|
13
|
-
@fragment_definitions = {}
|
14
|
-
end
|
15
|
-
|
16
|
-
def [](key)
|
17
|
-
warn "#{self.class}#[] is deprecated; use `operation_definitions[]` instead"
|
18
|
-
operation_definitions[key]
|
19
|
-
end
|
20
|
-
|
21
|
-
def each(&block)
|
22
|
-
warn "#{self.class}#each is deprecated; use `operation_definitions.each` instead"
|
23
|
-
operation_definitions.each(&block)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,206 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module InternalRepresentation
|
4
|
-
class Node
|
5
|
-
# @api private
|
6
|
-
DEFAULT_TYPED_CHILDREN = Proc.new { |h, k| h[k] = {} }
|
7
|
-
|
8
|
-
# A specialized, reusable object for leaf nodes.
|
9
|
-
NO_TYPED_CHILDREN = Hash.new({}.freeze)
|
10
|
-
def NO_TYPED_CHILDREN.dup; self; end;
|
11
|
-
NO_TYPED_CHILDREN.freeze
|
12
|
-
|
13
|
-
# @return [String] the name this node has in the response
|
14
|
-
attr_reader :name
|
15
|
-
|
16
|
-
# @return [GraphQL::ObjectType]
|
17
|
-
attr_reader :owner_type
|
18
|
-
|
19
|
-
# Each key is a {GraphQL::ObjectType} which this selection _may_ be made on.
|
20
|
-
# The values for that key are selections which apply to that type.
|
21
|
-
#
|
22
|
-
# This value is derived from {#scoped_children} after the rewrite is finished.
|
23
|
-
# @return [Hash<GraphQL::ObjectType, Hash<String => Node>>]
|
24
|
-
def typed_children
|
25
|
-
@typed_children ||= begin
|
26
|
-
if @scoped_children.any?
|
27
|
-
new_tc = Hash.new(&DEFAULT_TYPED_CHILDREN)
|
28
|
-
all_object_types = Set.new
|
29
|
-
scoped_children.each_key { |t| all_object_types.merge(@query.possible_types(t)) }
|
30
|
-
# Remove any scoped children which don't follow this return type
|
31
|
-
# (This can happen with fragment merging where lexical scope is lost)
|
32
|
-
all_object_types &= @query.possible_types(@return_type.unwrap)
|
33
|
-
all_object_types.each do |t|
|
34
|
-
new_tc[t] = get_typed_children(t)
|
35
|
-
end
|
36
|
-
new_tc
|
37
|
-
else
|
38
|
-
NO_TYPED_CHILDREN
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# These children correspond closely to scopes in the AST.
|
45
|
-
# Keys _may_ be abstract types. They're assumed to be read-only after rewrite is finished
|
46
|
-
# because {#typed_children} is derived from them.
|
47
|
-
#
|
48
|
-
# Using {#scoped_children} during the rewrite step reduces the overhead of reifying
|
49
|
-
# abstract types because they're only reified _after_ the rewrite.
|
50
|
-
# @return [Hash<GraphQL::BaseType, Hash<String => Node>>]
|
51
|
-
attr_reader :scoped_children
|
52
|
-
|
53
|
-
# @return [Array<Language::Nodes::AbstractNode>] AST nodes which are represented by this node
|
54
|
-
attr_reader :ast_nodes
|
55
|
-
|
56
|
-
# @return [Array<GraphQL::Field>] Field definitions for this node (there should only be one!)
|
57
|
-
attr_reader :definitions
|
58
|
-
|
59
|
-
# @return [GraphQL::BaseType] The expected wrapped type this node must return.
|
60
|
-
attr_reader :return_type
|
61
|
-
|
62
|
-
# @return [InternalRepresentation::Node, nil]
|
63
|
-
attr_reader :parent
|
64
|
-
|
65
|
-
def initialize(
|
66
|
-
name:, owner_type:, query:, return_type:, parent:,
|
67
|
-
ast_nodes: [],
|
68
|
-
definitions: []
|
69
|
-
)
|
70
|
-
@name = name
|
71
|
-
@query = query
|
72
|
-
@owner_type = owner_type
|
73
|
-
@parent = parent
|
74
|
-
@typed_children = nil
|
75
|
-
@scoped_children = Hash.new { |h1, k1| h1[k1] = {} }
|
76
|
-
@ast_nodes = ast_nodes
|
77
|
-
@definitions = definitions
|
78
|
-
@return_type = return_type
|
79
|
-
end
|
80
|
-
|
81
|
-
def initialize_copy(other_node)
|
82
|
-
super
|
83
|
-
# Bust some caches:
|
84
|
-
@typed_children = nil
|
85
|
-
@definition = nil
|
86
|
-
@definition_name = nil
|
87
|
-
@ast_node = nil
|
88
|
-
# Shallow-copy some state:
|
89
|
-
@scoped_children = other_node.scoped_children.dup
|
90
|
-
@ast_nodes = other_node.ast_nodes.dup
|
91
|
-
@definitions = other_node.definitions.dup
|
92
|
-
end
|
93
|
-
|
94
|
-
def ==(other)
|
95
|
-
other.is_a?(self.class) &&
|
96
|
-
other.name == name &&
|
97
|
-
other.parent == parent &&
|
98
|
-
other.return_type == return_type &&
|
99
|
-
other.owner_type == owner_type &&
|
100
|
-
other.scoped_children == scoped_children &&
|
101
|
-
other.definitions == definitions &&
|
102
|
-
other.ast_nodes == ast_nodes
|
103
|
-
end
|
104
|
-
|
105
|
-
def definition_name
|
106
|
-
definition && definition.name
|
107
|
-
end
|
108
|
-
|
109
|
-
def arguments
|
110
|
-
@query.arguments_for(self, definition)
|
111
|
-
end
|
112
|
-
|
113
|
-
def definition
|
114
|
-
@definition ||= begin
|
115
|
-
first_def = @definitions.first
|
116
|
-
first_def && @query.get_field(@owner_type, first_def.name)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def ast_node
|
121
|
-
@ast_node ||= ast_nodes.first
|
122
|
-
end
|
123
|
-
|
124
|
-
def inspect
|
125
|
-
all_children_names = scoped_children.values.map(&:keys).flatten.uniq.join(", ")
|
126
|
-
all_locations = ast_nodes.map {|n| "#{n.line}:#{n.col}" }.join(", ")
|
127
|
-
"#<Node #{@owner_type}.#{@name} -> #{@return_type} {#{all_children_names}} @ [#{all_locations}] #{object_id}>"
|
128
|
-
end
|
129
|
-
|
130
|
-
# Merge selections from `new_parent` into `self`.
|
131
|
-
# Selections are merged in place, not copied.
|
132
|
-
def deep_merge_node(new_parent, scope: nil, merge_self: true)
|
133
|
-
if merge_self
|
134
|
-
@ast_nodes |= new_parent.ast_nodes
|
135
|
-
@definitions |= new_parent.definitions
|
136
|
-
end
|
137
|
-
new_sc = new_parent.scoped_children
|
138
|
-
if new_sc.any?
|
139
|
-
scope ||= Scope.new(@query, @return_type.unwrap)
|
140
|
-
new_sc.each do |obj_type, new_fields|
|
141
|
-
inner_scope = scope.enter(obj_type)
|
142
|
-
inner_scope.each do |scoped_type|
|
143
|
-
prev_fields = @scoped_children[scoped_type]
|
144
|
-
new_fields.each do |name, new_node|
|
145
|
-
prev_node = prev_fields[name]
|
146
|
-
if prev_node
|
147
|
-
prev_node.deep_merge_node(new_node)
|
148
|
-
else
|
149
|
-
prev_fields[name] = new_node
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
# @return [GraphQL::Query]
|
158
|
-
attr_reader :query
|
159
|
-
|
160
|
-
def subscription_topic
|
161
|
-
@subscription_topic ||= begin
|
162
|
-
scope = if definition.subscription_scope
|
163
|
-
@query.context[definition.subscription_scope]
|
164
|
-
else
|
165
|
-
nil
|
166
|
-
end
|
167
|
-
Subscriptions::Event.serialize(
|
168
|
-
definition_name,
|
169
|
-
@query.arguments_for(self, definition),
|
170
|
-
definition,
|
171
|
-
scope: scope
|
172
|
-
)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
protected
|
177
|
-
|
178
|
-
attr_writer :owner_type, :parent
|
179
|
-
|
180
|
-
private
|
181
|
-
|
182
|
-
# Get applicable children from {#scoped_children}
|
183
|
-
# @param obj_type [GraphQL::ObjectType]
|
184
|
-
# @return [Hash<String => Node>]
|
185
|
-
def get_typed_children(obj_type)
|
186
|
-
new_tc = {}
|
187
|
-
@scoped_children.each do |scope_type, scope_nodes|
|
188
|
-
if GraphQL::Execution::Typecast.subtype?(scope_type, obj_type)
|
189
|
-
scope_nodes.each do |name, new_node|
|
190
|
-
prev_node = new_tc[name]
|
191
|
-
if prev_node
|
192
|
-
prev_node.deep_merge_node(new_node)
|
193
|
-
else
|
194
|
-
copied_node = new_node.dup
|
195
|
-
copied_node.owner_type = obj_type
|
196
|
-
copied_node.parent = self
|
197
|
-
new_tc[name] = copied_node
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
new_tc
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module InternalRepresentation
|
4
|
-
module Print
|
5
|
-
module_function
|
6
|
-
|
7
|
-
def print(schema, query_string)
|
8
|
-
query = GraphQL::Query.new(schema, query_string)
|
9
|
-
print_node(query.irep_selection)
|
10
|
-
end
|
11
|
-
|
12
|
-
def print_node(node, indent: 0)
|
13
|
-
padding = " " * indent
|
14
|
-
typed_children_padding = " " * (indent + 2)
|
15
|
-
query_str = "".dup
|
16
|
-
|
17
|
-
if !node.definition
|
18
|
-
op_node = node.ast_node
|
19
|
-
name = op_node.name ? " " + op_node.name : ""
|
20
|
-
op_type = op_node.operation_type
|
21
|
-
query_str << "#{op_type}#{name}"
|
22
|
-
else
|
23
|
-
if node.name == node.definition_name
|
24
|
-
query_str << "#{padding}#{node.name}"
|
25
|
-
else
|
26
|
-
query_str << "#{padding}#{node.name}: #{node.definition_name}"
|
27
|
-
end
|
28
|
-
|
29
|
-
args = node.ast_nodes.map { |n| n.arguments.map(&:to_query_string).join(",") }.uniq
|
30
|
-
query_str << args.map { |a| "(#{a})"}.join("|")
|
31
|
-
end
|
32
|
-
|
33
|
-
if node.typed_children.any?
|
34
|
-
query_str << " {\n"
|
35
|
-
node.typed_children.each do |type, children|
|
36
|
-
query_str << "#{typed_children_padding}... on #{type.name} {\n"
|
37
|
-
children.each do |name, child|
|
38
|
-
query_str << print_node(child, indent: indent + 4)
|
39
|
-
end
|
40
|
-
query_str << "#{typed_children_padding}}\n"
|
41
|
-
end
|
42
|
-
query_str << "#{padding}}\n"
|
43
|
-
else
|
44
|
-
query_str << "\n"
|
45
|
-
end
|
46
|
-
|
47
|
-
query_str
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|