graphql 1.8.7 → 1.9.0
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 +2 -1
- data/lib/generators/graphql/scalar_generator.rb +20 -0
- data/lib/generators/graphql/templates/base_scalar.erb +4 -0
- data/lib/generators/graphql/templates/scalar.erb +13 -0
- data/lib/graphql/analysis/ast/analyzer.rb +62 -0
- data/lib/graphql/analysis/ast/field_usage.rb +28 -0
- data/lib/graphql/analysis/ast/max_query_complexity.rb +23 -0
- data/lib/graphql/analysis/ast/max_query_depth.rb +18 -0
- data/lib/graphql/analysis/ast/query_complexity.rb +114 -0
- data/lib/graphql/analysis/ast/query_depth.rb +66 -0
- data/lib/graphql/analysis/ast/visitor.rb +255 -0
- data/lib/graphql/analysis/ast.rb +82 -0
- data/lib/graphql/analysis.rb +1 -0
- data/lib/graphql/argument.rb +5 -0
- data/lib/graphql/authorization.rb +1 -0
- data/lib/graphql/backwards_compatibility.rb +1 -1
- data/lib/graphql/base_type.rb +1 -1
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +1 -2
- data/lib/graphql/compatibility/schema_parser_specification.rb +2 -6
- data/lib/graphql/dig.rb +19 -0
- data/lib/graphql/directive/include_directive.rb +1 -7
- data/lib/graphql/directive/skip_directive.rb +1 -8
- data/lib/graphql/directive.rb +13 -1
- data/lib/graphql/enum_type.rb +8 -0
- data/lib/graphql/execution/execute.rb +36 -17
- data/lib/graphql/execution/instrumentation.rb +2 -0
- data/lib/graphql/execution/interpreter/execution_errors.rb +29 -0
- data/lib/graphql/execution/interpreter/hash_response.rb +46 -0
- data/lib/graphql/execution/interpreter/resolve.rb +58 -0
- data/lib/graphql/execution/interpreter/runtime.rb +597 -0
- data/lib/graphql/execution/interpreter.rb +99 -0
- data/lib/graphql/execution/lazy.rb +8 -1
- data/lib/graphql/execution/lookahead.rb +351 -0
- data/lib/graphql/execution/multiplex.rb +37 -29
- data/lib/graphql/execution.rb +2 -0
- data/lib/graphql/execution_error.rb +1 -1
- data/lib/graphql/field.rb +1 -7
- data/lib/graphql/integer_encoding_error.rb +12 -0
- data/lib/graphql/internal_representation/rewrite.rb +127 -142
- data/lib/graphql/introspection/dynamic_fields.rb +8 -2
- data/lib/graphql/introspection/entry_points.rb +11 -6
- data/lib/graphql/introspection/enum_value_type.rb +4 -0
- data/lib/graphql/introspection/schema_type.rb +7 -2
- data/lib/graphql/introspection/type_type.rb +9 -5
- data/lib/graphql/invalid_null_error.rb +1 -1
- data/lib/graphql/language/block_string.rb +37 -0
- data/lib/graphql/language/document_from_schema_definition.rb +10 -7
- data/lib/graphql/language/lexer.rb +55 -36
- data/lib/graphql/language/lexer.rl +8 -3
- data/lib/graphql/language/nodes.rb +440 -362
- data/lib/graphql/language/parser.rb +56 -56
- data/lib/graphql/language/parser.y +12 -12
- data/lib/graphql/language/printer.rb +2 -2
- data/lib/graphql/language/visitor.rb +158 -15
- data/lib/graphql/language.rb +0 -1
- data/lib/graphql/literal_validation_error.rb +6 -0
- data/lib/graphql/query/arguments.rb +3 -2
- data/lib/graphql/query/arguments_cache.rb +1 -1
- data/lib/graphql/query/context.rb +14 -5
- data/lib/graphql/query/executor.rb +1 -1
- data/lib/graphql/query/result.rb +1 -1
- data/lib/graphql/query/validation_pipeline.rb +35 -11
- data/lib/graphql/query/variable_validation_error.rb +10 -1
- data/lib/graphql/query.rb +16 -2
- data/lib/graphql/relay/base_connection.rb +2 -0
- data/lib/graphql/relay/connection_instrumentation.rb +3 -1
- data/lib/graphql/relay/connection_resolve.rb +1 -1
- data/lib/graphql/relay/node.rb +2 -28
- data/lib/graphql/relay/relation_connection.rb +1 -1
- data/lib/graphql/schema/argument.rb +13 -5
- data/lib/graphql/schema/base_64_encoder.rb +4 -4
- data/lib/graphql/schema/build_from_definition.rb +2 -4
- data/lib/graphql/schema/default_type_error.rb +1 -1
- data/lib/graphql/schema/directive/feature.rb +66 -0
- data/lib/graphql/schema/directive/include.rb +25 -0
- data/lib/graphql/schema/directive/skip.rb +25 -0
- data/lib/graphql/schema/directive/transform.rb +48 -0
- data/lib/graphql/schema/directive.rb +103 -0
- data/lib/graphql/schema/enum_value.rb +3 -2
- data/lib/graphql/schema/field/connection_extension.rb +50 -0
- data/lib/graphql/schema/field/scope_extension.rb +18 -0
- data/lib/graphql/schema/field.rb +273 -64
- data/lib/graphql/schema/field_extension.rb +69 -0
- data/lib/graphql/schema/input_object.rb +16 -8
- data/lib/graphql/schema/interface.rb +1 -0
- data/lib/graphql/schema/loader.rb +22 -16
- data/lib/graphql/schema/member/base_dsl_methods.rb +8 -2
- data/lib/graphql/schema/member/build_type.rb +33 -1
- data/lib/graphql/schema/member/has_arguments.rb +6 -2
- data/lib/graphql/schema/member/has_fields.rb +18 -70
- data/lib/graphql/schema/member/has_path.rb +25 -0
- data/lib/graphql/schema/member/instrumentation.rb +10 -7
- data/lib/graphql/schema/member.rb +2 -0
- data/lib/graphql/schema/mutation.rb +6 -48
- data/lib/graphql/schema/non_null.rb +5 -1
- data/lib/graphql/schema/object.rb +18 -4
- data/lib/graphql/schema/printer.rb +1 -1
- data/lib/graphql/schema/relay_classic_mutation.rb +42 -9
- data/lib/graphql/schema/resolver/has_payload_type.rb +65 -0
- data/lib/graphql/schema/resolver.rb +45 -20
- data/lib/graphql/schema/subscription.rb +97 -0
- data/lib/graphql/schema/traversal.rb +11 -7
- data/lib/graphql/schema.rb +186 -38
- data/lib/graphql/static_validation/all_rules.rb +3 -2
- data/lib/graphql/static_validation/base_visitor.rb +199 -0
- data/lib/graphql/static_validation/default_visitor.rb +15 -0
- data/lib/graphql/static_validation/definition_dependencies.rb +62 -68
- data/lib/graphql/static_validation/{message.rb → error.rb} +11 -11
- data/lib/graphql/static_validation/interpreter_visitor.rb +14 -0
- data/lib/graphql/static_validation/literal_validator.rb +54 -11
- data/lib/graphql/static_validation/no_validate_visitor.rb +10 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +87 -16
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +31 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +11 -11
- data/lib/graphql/static_validation/rules/argument_names_are_unique_error.rb +30 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +52 -8
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +35 -0
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +12 -15
- data/lib/graphql/static_validation/rules/directives_are_defined_error.rb +29 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +19 -14
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb +31 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +17 -19
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb +32 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +30 -14
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb +31 -0
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +356 -29
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +32 -0
- data/lib/graphql/static_validation/rules/fragment_names_are_unique.rb +20 -13
- data/lib/graphql/static_validation/rules/fragment_names_are_unique_error.rb +29 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +37 -29
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb +35 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +25 -17
- data/lib/graphql/static_validation/rules/fragment_types_exist_error.rb +29 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +12 -10
- data/lib/graphql/static_validation/rules/fragments_are_finite_error.rb +29 -0
- data/lib/graphql/static_validation/rules/fragments_are_named.rb +7 -11
- data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +26 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +16 -16
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types_error.rb +30 -0
- data/lib/graphql/static_validation/rules/fragments_are_used.rb +21 -14
- data/lib/graphql/static_validation/rules/fragments_are_used_error.rb +29 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +10 -14
- data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +26 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +30 -30
- data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +25 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid.rb +25 -17
- data/lib/graphql/static_validation/rules/operation_names_are_valid_error.rb +28 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +17 -18
- data/lib/graphql/static_validation/rules/required_arguments_are_present_error.rb +35 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +47 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +35 -0
- data/lib/graphql/static_validation/rules/subscription_root_exists.rb +10 -14
- data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +26 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +28 -17
- data/lib/graphql/static_validation/rules/unique_directives_per_location_error.rb +29 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +35 -27
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb +39 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +15 -14
- data/lib/graphql/static_validation/rules/variable_names_are_unique_error.rb +29 -0
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +41 -30
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb +38 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +18 -14
- data/lib/graphql/static_validation/rules/variables_are_input_types_error.rb +32 -0
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +73 -65
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb +37 -0
- data/lib/graphql/static_validation/validation_context.rb +8 -51
- data/lib/graphql/static_validation/validator.rb +23 -15
- data/lib/graphql/static_validation.rb +5 -3
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +21 -2
- data/lib/graphql/subscriptions/event.rb +28 -5
- data/lib/graphql/subscriptions/subscription_root.rb +66 -0
- data/lib/graphql/subscriptions.rb +16 -2
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +0 -1
- data/lib/graphql/tracing/appsignal_tracing.rb +1 -1
- data/lib/graphql/tracing/data_dog_tracing.rb +1 -1
- data/lib/graphql/tracing/new_relic_tracing.rb +3 -3
- data/lib/graphql/tracing/platform_tracing.rb +17 -1
- data/lib/graphql/tracing/prometheus_tracing.rb +1 -1
- data/lib/graphql/tracing/scout_tracing.rb +1 -1
- data/lib/graphql/tracing/skylight_tracing.rb +3 -3
- data/lib/graphql/tracing.rb +8 -8
- data/lib/graphql/types/float.rb +1 -1
- data/lib/graphql/types/int.rb +11 -2
- data/lib/graphql/types/iso_8601_date_time.rb +15 -1
- data/lib/graphql/types/relay/base_connection.rb +15 -1
- data/lib/graphql/types/relay/node.rb +0 -1
- data/lib/graphql/types/relay/node_field.rb +43 -0
- data/lib/graphql/types/relay/nodes_field.rb +45 -0
- data/lib/graphql/types/relay.rb +2 -0
- data/lib/graphql/unauthorized_error.rb +4 -0
- data/lib/graphql/unauthorized_field_error.rb +23 -0
- data/lib/graphql/upgrader/member.rb +5 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +6 -1
- data/readme.md +7 -7
- data/spec/dummy/Gemfile +1 -1
- data/spec/dummy/Gemfile.lock +157 -0
- data/spec/dummy/app/channels/graphql_channel.rb +22 -11
- data/spec/dummy/config/locales/en.yml +1 -1
- data/spec/dummy/log/test.log +199 -0
- data/spec/dummy/test/test_helper.rb +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4w/4wzXRZrAkwKdgYaSE0pid5eB-fer8vSfSku_NPg4rMA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7I/7IHVBiJT06QSpgLpLoJIxboQ0B-D_tMTxsvoezBTV3Q.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8w/8wY_SKagj8wHuwGNAAf6JnQ8joMbC6cEYpHrTAI8Urc.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/AK/AKzz1u6bGb4auXcrObA_g5LL-oV0ejNGa448AgAi_WQ.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ET/ETW4uxvaYpruL8y6_ZptUH82ZowMaHIqvg5WexBFdEM.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/F1/F1TWpjjyA56k9Z90n5B3xRn7DUdGjX73QCkYC6k07JQ.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/F8/F8MUNRzORGFgr329fNM0xLaoWCXdv3BIalT7dsvLfjs.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/KB/KB07ZaKNC5uXJ7TjLi-WqnY6g7dq8wWp_8N3HNjBNxg.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ms/MsKSimH_UCB-H1tLvDABDHuvGciuoW6kVqQWDrXU5FQ.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Mt/Mtci-Kim50aPOmeClD4AIicKn1d1WJ0n454IjSd94sk.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/QH/QHt3Tc1Y6M66Oo_pDuMyWrQNs4Pp3SMeZR5K1wJj2Ts.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/XU/XU4k1OXnfMils5SrirorPvDSyDSqiOWLZNtmAH1HH8k.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ZI/ZIof7mZxWWCnraIFOCuV6a8QRWzKJXJnx2Xd7C0ZyX0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cG/cGc_puuPS5pZKgUcy1Y_i1L6jl5UtsiIrMH59rTzR6c.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/df/dfro_B6bx3KP1Go-7jEOqqZ2j4hVRseXIc3es9PKQno.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jO/jO1DfbqnG0mTULsjJJANc3fefrG2zt7DIMmcptMT628.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pE/pE7gO6pQ-z187Swb4hT554wmqsq-cNzgPWLrCz-LQQQ.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/r9/r9iU1l58a6rxkZSW5RSC52_tD-_UQuHxoMVnkfJ7Mhs.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xi/xitPPFfPIyDMpaznV0sBBcw8eSCV8PJcLLWin78sCgE.cache +0 -0
- data/spec/dummy/tmp/screenshots/failures_test_it_handles_subscriptions.png +0 -0
- data/spec/graphql/analysis/analyze_query_spec.rb +1 -1
- data/spec/graphql/analysis/ast/field_usage_spec.rb +51 -0
- data/spec/graphql/analysis/ast/max_query_complexity_spec.rb +120 -0
- data/spec/graphql/analysis/ast/max_query_depth_spec.rb +114 -0
- data/spec/graphql/analysis/ast/query_complexity_spec.rb +299 -0
- data/spec/graphql/analysis/ast/query_depth_spec.rb +108 -0
- data/spec/graphql/analysis/ast_spec.rb +269 -0
- data/spec/graphql/authorization_spec.rb +120 -23
- data/spec/graphql/base_type_spec.rb +6 -4
- data/spec/graphql/enum_type_spec.rb +6 -1
- data/spec/graphql/execution/execute_spec.rb +9 -9
- data/spec/graphql/execution/instrumentation_spec.rb +19 -0
- data/spec/graphql/execution/interpreter_spec.rb +485 -0
- data/spec/graphql/execution/lazy_spec.rb +67 -1
- data/spec/graphql/execution/lookahead_spec.rb +363 -0
- data/spec/graphql/execution/multiplex_spec.rb +31 -3
- data/spec/graphql/execution/typecast_spec.rb +20 -20
- data/spec/graphql/execution_error_spec.rb +110 -96
- data/spec/graphql/field_spec.rb +1 -1
- data/spec/graphql/input_object_type_spec.rb +13 -352
- data/spec/graphql/int_type_spec.rb +19 -0
- data/spec/graphql/interface_type_spec.rb +4 -4
- data/spec/graphql/internal_representation/rewrite_spec.rb +2 -0
- data/spec/graphql/introspection/input_value_type_spec.rb +1 -1
- data/spec/graphql/introspection/type_type_spec.rb +1 -2
- data/spec/graphql/language/document_from_schema_definition_spec.rb +2 -2
- data/spec/graphql/language/lexer_spec.rb +72 -3
- data/spec/graphql/language/nodes_spec.rb +20 -0
- data/spec/graphql/language/printer_spec.rb +18 -6
- data/spec/graphql/language/visitor_spec.rb +320 -14
- data/spec/graphql/non_null_type_spec.rb +1 -1
- data/spec/graphql/object_type_spec.rb +32 -27
- data/spec/graphql/query/arguments_spec.rb +21 -0
- data/spec/graphql/query/context_spec.rb +28 -0
- data/spec/graphql/query/executor_spec.rb +40 -36
- data/spec/graphql/query_spec.rb +12 -6
- data/spec/graphql/schema/argument_spec.rb +35 -1
- data/spec/graphql/schema/build_from_definition_spec.rb +144 -29
- data/spec/graphql/schema/catchall_middleware_spec.rb +16 -15
- data/spec/graphql/schema/directive/feature_spec.rb +81 -0
- data/spec/graphql/schema/directive/transform_spec.rb +39 -0
- data/spec/graphql/schema/enum_spec.rb +12 -3
- data/spec/graphql/schema/enum_value_spec.rb +11 -0
- data/spec/graphql/schema/field_extension_spec.rb +115 -0
- data/spec/graphql/schema/field_spec.rb +47 -7
- data/spec/graphql/schema/input_object_spec.rb +95 -0
- data/spec/graphql/schema/instrumentation_spec.rb +3 -0
- data/spec/graphql/schema/interface_spec.rb +8 -2
- data/spec/graphql/schema/introspection_system_spec.rb +9 -1
- data/spec/graphql/schema/loader_spec.rb +5 -0
- data/spec/graphql/schema/member/accepts_definition_spec.rb +4 -0
- data/spec/graphql/schema/member/build_type_spec.rb +46 -0
- data/spec/graphql/schema/member/scoped_spec.rb +19 -3
- data/spec/graphql/schema/mutation_spec.rb +5 -3
- data/spec/graphql/schema/object_spec.rb +9 -1
- data/spec/graphql/schema/printer_spec.rb +255 -93
- data/spec/graphql/schema/relay_classic_mutation_spec.rb +133 -0
- data/spec/graphql/schema/resolver_spec.rb +173 -9
- data/spec/graphql/schema/scalar_spec.rb +6 -0
- data/spec/graphql/schema/subscription_spec.rb +416 -0
- data/spec/graphql/schema/traversal_spec.rb +10 -10
- data/spec/graphql/schema/type_expression_spec.rb +2 -2
- data/spec/graphql/schema/union_spec.rb +7 -0
- data/spec/graphql/schema/validation_spec.rb +1 -1
- data/spec/graphql/schema/warden_spec.rb +145 -88
- data/spec/graphql/static_validation/rules/argument_literals_are_compatible_spec.rb +213 -73
- data/spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb +2 -2
- data/spec/graphql/static_validation/rules/arguments_are_defined_spec.rb +72 -29
- data/spec/graphql/static_validation/rules/directives_are_defined_spec.rb +4 -2
- data/spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb +4 -2
- data/spec/graphql/static_validation/rules/fields_are_defined_on_type_spec.rb +10 -5
- data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +10 -5
- data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +131 -5
- data/spec/graphql/static_validation/rules/fragment_names_are_unique_spec.rb +2 -1
- data/spec/graphql/static_validation/rules/fragment_spreads_are_possible_spec.rb +6 -3
- data/spec/graphql/static_validation/rules/fragment_types_exist_spec.rb +4 -2
- data/spec/graphql/static_validation/rules/fragments_are_finite_spec.rb +4 -2
- data/spec/graphql/static_validation/rules/fragments_are_named_spec.rb +2 -1
- data/spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb +6 -3
- data/spec/graphql/static_validation/rules/fragments_are_used_spec.rb +22 -2
- data/spec/graphql/static_validation/rules/mutation_root_exists_spec.rb +2 -1
- data/spec/graphql/static_validation/rules/operation_names_are_valid_spec.rb +6 -3
- data/spec/graphql/static_validation/rules/required_arguments_are_present_spec.rb +13 -4
- data/spec/graphql/static_validation/rules/required_input_object_attributes_are_present_spec.rb +58 -0
- data/spec/graphql/static_validation/rules/subscription_root_exists_spec.rb +2 -1
- data/spec/graphql/static_validation/rules/unique_directives_per_location_spec.rb +14 -7
- data/spec/graphql/static_validation/rules/variable_default_values_are_correctly_typed_spec.rb +14 -7
- data/spec/graphql/static_validation/rules/variable_usages_are_allowed_spec.rb +8 -4
- data/spec/graphql/static_validation/rules/variables_are_input_types_spec.rb +8 -4
- data/spec/graphql/static_validation/rules/variables_are_used_and_defined_spec.rb +23 -3
- data/spec/graphql/static_validation/type_stack_spec.rb +10 -19
- data/spec/graphql/static_validation/validator_spec.rb +50 -2
- data/spec/graphql/subscriptions_spec.rb +27 -16
- data/spec/graphql/tracing/new_relic_tracing_spec.rb +16 -0
- data/spec/graphql/tracing/platform_tracing_spec.rb +59 -37
- data/spec/graphql/tracing/prometheus_tracing_spec.rb +3 -0
- data/spec/graphql/tracing/skylight_tracing_spec.rb +16 -0
- data/spec/graphql/types/iso_8601_date_time_spec.rb +29 -2
- data/spec/graphql/union_type_spec.rb +2 -2
- data/spec/graphql/upgrader/member_spec.rb +67 -0
- data/spec/{graphql → integration/mongoid/graphql}/relay/mongo_relation_connection_spec.rb +11 -22
- data/spec/integration/mongoid/spec_helper.rb +2 -0
- data/spec/{support → integration/mongoid}/star_trek/data.rb +0 -0
- data/spec/{support → integration/mongoid}/star_trek/schema.rb +56 -34
- data/spec/{support/star_wars → integration/rails}/data.rb +1 -0
- data/spec/{support → integration/rails/generators}/base_generator_test.rb +0 -0
- data/spec/{generators → integration/rails/generators}/graphql/enum_generator_spec.rb +0 -0
- data/spec/{generators → integration/rails/generators}/graphql/install_generator_spec.rb +1 -1
- data/spec/{generators → integration/rails/generators}/graphql/interface_generator_spec.rb +0 -0
- data/spec/{generators → integration/rails/generators}/graphql/loader_generator_spec.rb +0 -0
- data/spec/{generators → integration/rails/generators}/graphql/mutation_generator_spec.rb +0 -0
- data/spec/{generators → integration/rails/generators}/graphql/object_generator_spec.rb +0 -0
- data/spec/integration/rails/generators/graphql/scalar_generator_spec.rb +28 -0
- data/spec/{generators → integration/rails/generators}/graphql/union_generator_spec.rb +0 -0
- data/spec/integration/rails/graphql/input_object_type_spec.rb +364 -0
- data/spec/{graphql → integration/rails/graphql}/query/variables_spec.rb +7 -7
- data/spec/{graphql → integration/rails/graphql}/relay/array_connection_spec.rb +9 -9
- data/spec/{graphql → integration/rails/graphql}/relay/base_connection_spec.rb +11 -3
- data/spec/{graphql → integration/rails/graphql}/relay/connection_instrumentation_spec.rb +19 -22
- data/spec/{graphql → integration/rails/graphql}/relay/connection_resolve_spec.rb +16 -0
- data/spec/{graphql → integration/rails/graphql}/relay/connection_type_spec.rb +0 -0
- data/spec/{graphql → integration/rails/graphql}/relay/edge_spec.rb +0 -0
- data/spec/{graphql → integration/rails/graphql}/relay/mutation_spec.rb +48 -0
- data/spec/{graphql → integration/rails/graphql}/relay/node_spec.rb +0 -0
- data/spec/{graphql → integration/rails/graphql}/relay/page_info_spec.rb +22 -22
- data/spec/{graphql → integration/rails/graphql}/relay/range_add_spec.rb +4 -4
- data/spec/{graphql → integration/rails/graphql}/relay/relation_connection_spec.rb +56 -27
- data/spec/{graphql → integration/rails/graphql}/schema_spec.rb +15 -11
- data/spec/{graphql → integration/rails/graphql}/tracing/active_support_notifications_tracing_spec.rb +16 -9
- data/spec/integration/rails/spec_helper.rb +25 -0
- data/spec/integration/tmp/app/graphql/types/family_type.rb +9 -0
- data/spec/spec_helper.rb +23 -39
- data/spec/support/dummy/data.rb +20 -17
- data/spec/support/dummy/schema.rb +315 -305
- data/spec/support/error_bubbling_helpers.rb +23 -0
- data/spec/support/jazz.rb +213 -46
- data/spec/support/lazy_helpers.rb +69 -27
- data/spec/support/new_relic.rb +3 -0
- data/spec/support/skylight.rb +3 -0
- data/spec/support/star_wars/schema.rb +131 -81
- data/spec/support/static_validation_helpers.rb +9 -5
- metadata +418 -261
- data/lib/graphql/language/comments.rb +0 -45
- data/lib/graphql/static_validation/arguments_validator.rb +0 -50
- data/spec/graphql/schema/member/has_fields_spec.rb +0 -129
- data/spec/rails_dependency_sanity_spec.rb +0 -14
@@ -28,7 +28,7 @@ def parse_document
|
|
28
28
|
end
|
29
29
|
# From the tokens, build an AST
|
30
30
|
@tracer.trace("parse", {query_string: @query_string}) do
|
31
|
-
if @tokens.
|
31
|
+
if @tokens.empty?
|
32
32
|
make_node(:Document, definitions: [], filename: @filename)
|
33
33
|
else
|
34
34
|
do_parse
|
@@ -476,24 +476,24 @@ racc_action_default = [
|
|
476
476
|
-93, -97, -99, -99, -165, -160 ]
|
477
477
|
|
478
478
|
racc_goto_table = [
|
479
|
-
10, 72, 59, 10, 91, 195, 129,
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
171,
|
484
|
-
|
485
|
-
|
486
|
-
117,
|
487
|
-
|
488
|
-
148, 150, 151,
|
489
|
-
|
490
|
-
|
491
|
-
nil, nil, 172, 180,
|
492
|
-
nil, 202,
|
493
|
-
nil, nil,
|
494
|
-
202, nil, nil, 202, nil, nil, nil, nil, nil,
|
495
|
-
nil, nil, nil,
|
496
|
-
nil, nil, nil,
|
479
|
+
10, 72, 59, 10, 91, 195, 129, 164, 133, 68,
|
480
|
+
102, 203, 283, 259, 227, 202, 92, 175, 119, 37,
|
481
|
+
125, 235, 37, 274, 182, 270, 245, 135, 271, 99,
|
482
|
+
274, 274, 301, 140, 118, 271, 141, 132, 304, 153,
|
483
|
+
171, 139, 152, 143, 145, 147, 149, 161, 97, 2,
|
484
|
+
167, 134, 288, 236, 311, 103, 88, 159, 246, 175,
|
485
|
+
95, 256, 99, 231, 177, 202, 266, 240, 4, 313,
|
486
|
+
117, 39, 247, 165, 121, 281, 241, 127, 179, 1,
|
487
|
+
276, 248, 249, 252, 40, 202, 183, 3, 144, 146,
|
488
|
+
148, 150, 151, 258, 154, 155, 156, 157, 286, 99,
|
489
|
+
292, 137, 202, 99, 255, 99, 251, 99, 124, 99,
|
490
|
+
221, 170, 294, 224, 67, 173, nil, 91, nil, nil,
|
491
|
+
nil, nil, 172, 180, 264, nil, 41, 65, nil, nil,
|
492
|
+
nil, 202, 264, nil, 189, 137, nil, 202, 137, 99,
|
493
|
+
nil, nil, 264, nil, nil, nil, nil, 197, nil, nil,
|
494
|
+
202, nil, nil, 202, nil, nil, nil, nil, nil, nil,
|
495
|
+
nil, nil, nil, 264, nil, nil, nil, nil, 201, nil,
|
496
|
+
nil, nil, nil, 264, nil, 65, nil, 137, nil, nil,
|
497
497
|
nil, nil, nil, nil, nil, nil, nil, 100, nil, nil,
|
498
498
|
104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
|
499
499
|
114, 115, nil, nil, nil, nil, 238, 242, 308, 122,
|
@@ -520,24 +520,24 @@ racc_goto_table = [
|
|
520
520
|
nil, nil, nil, nil, nil, nil, 309, nil, 293 ]
|
521
521
|
|
522
522
|
racc_goto_check = [
|
523
|
-
10, 13, 15, 10, 23, 79, 19,
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
19,
|
528
|
-
|
529
|
-
|
530
|
-
13,
|
531
|
-
|
532
|
-
13, 13, 13,
|
533
|
-
|
534
|
-
|
535
|
-
nil, nil, 15, 13,
|
536
|
-
nil, 29,
|
537
|
-
nil, nil,
|
538
|
-
29, nil, nil, 29, nil, nil, nil, nil, nil,
|
539
|
-
nil, nil, nil,
|
540
|
-
nil, nil, nil,
|
523
|
+
10, 13, 15, 10, 23, 79, 19, 22, 19, 28,
|
524
|
+
48, 36, 20, 45, 71, 29, 27, 55, 18, 32,
|
525
|
+
35, 71, 32, 78, 76, 30, 71, 54, 31, 49,
|
526
|
+
78, 78, 21, 70, 17, 31, 72, 14, 21, 70,
|
527
|
+
19, 48, 72, 48, 48, 48, 48, 18, 13, 2,
|
528
|
+
35, 27, 45, 73, 21, 13, 12, 14, 73, 55,
|
529
|
+
28, 36, 49, 76, 54, 29, 71, 33, 4, 20,
|
530
|
+
13, 4, 33, 27, 13, 81, 74, 13, 48, 1,
|
531
|
+
71, 74, 74, 22, 11, 29, 77, 3, 13, 13,
|
532
|
+
13, 13, 13, 44, 13, 13, 13, 13, 36, 49,
|
533
|
+
47, 10, 29, 49, 43, 49, 19, 49, 34, 49,
|
534
|
+
14, 13, 79, 14, 50, 13, nil, 23, nil, nil,
|
535
|
+
nil, nil, 15, 13, 80, nil, 16, 16, nil, nil,
|
536
|
+
nil, 29, 80, nil, 13, 10, nil, 29, 10, 49,
|
537
|
+
nil, nil, 80, nil, nil, nil, nil, 13, nil, nil,
|
538
|
+
29, nil, nil, 29, nil, nil, nil, nil, nil, nil,
|
539
|
+
nil, nil, nil, 80, nil, nil, nil, nil, 10, nil,
|
540
|
+
nil, nil, nil, 80, nil, 16, nil, 10, nil, nil,
|
541
541
|
nil, nil, nil, nil, nil, nil, nil, 16, nil, nil,
|
542
542
|
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
|
543
543
|
16, 16, nil, nil, nil, nil, 32, 32, 19, 16,
|
@@ -564,15 +564,15 @@ racc_goto_check = [
|
|
564
564
|
nil, nil, nil, nil, nil, nil, 16, nil, 16 ]
|
565
565
|
|
566
566
|
racc_goto_pointer = [
|
567
|
-
nil,
|
568
|
-
0,
|
569
|
-
-
|
570
|
-
-
|
571
|
-
nil, nil, nil, -
|
572
|
-
|
567
|
+
nil, 79, 49, 87, 68, nil, nil, nil, nil, nil,
|
568
|
+
0, 74, 16, -18, -60, -9, 116, -55, -71, -90,
|
569
|
+
-239, -252, -114, -55, nil, nil, nil, -49, -6, -153,
|
570
|
+
-213, -212, 19, -120, 14, -74, -157, nil, nil, nil,
|
571
|
+
nil, nil, nil, -114, -126, -206, nil, -161, -63, -40,
|
572
|
+
99, nil, nil, nil, -74, -118, nil, nil, nil, nil,
|
573
573
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
574
|
-
-
|
575
|
-
-
|
574
|
+
-72, -164, -69, -133, -112, nil, -118, -56, -218, -153,
|
575
|
+
-103, -175 ]
|
576
576
|
|
577
577
|
racc_goto_default = [
|
578
578
|
nil, nil, nil, nil, nil, 5, 6, 7, 8, 9,
|
@@ -1246,7 +1246,7 @@ module_eval(<<'.,.,', 'parser.y', 116)
|
|
1246
1246
|
|
1247
1247
|
module_eval(<<'.,.,', 'parser.y', 159)
|
1248
1248
|
def _reduce_60(val, _values, result)
|
1249
|
-
return make_node(:EnumValueDefinition, name: val[1], directives: val[2], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
1249
|
+
return make_node(:EnumValueDefinition, name: val[1], directives: val[2], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
1250
1250
|
result
|
1251
1251
|
end
|
1252
1252
|
.,.,
|
@@ -1572,7 +1572,7 @@ module_eval(<<'.,.,', 'parser.y', 273)
|
|
1572
1572
|
|
1573
1573
|
module_eval(<<'.,.,', 'parser.y', 282)
|
1574
1574
|
def _reduce_113(val, _values, result)
|
1575
|
-
return make_node(:SchemaDefinition, position_source: val[0], directives: val[1], **val[3])
|
1575
|
+
return make_node(:SchemaDefinition, position_source: val[0], definition_line: val[0].line, directives: val[1], **val[3])
|
1576
1576
|
result
|
1577
1577
|
end
|
1578
1578
|
.,.,
|
@@ -1734,7 +1734,7 @@ module_eval(<<'.,.,', 'parser.y', 338)
|
|
1734
1734
|
|
1735
1735
|
module_eval(<<'.,.,', 'parser.y', 348)
|
1736
1736
|
def _reduce_149(val, _values, result)
|
1737
|
-
return make_node(:ScalarTypeDefinition, name: val[2], directives: val[3], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
1737
|
+
return make_node(:ScalarTypeDefinition, name: val[2], directives: val[3], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
1738
1738
|
|
1739
1739
|
result
|
1740
1740
|
end
|
@@ -1742,7 +1742,7 @@ module_eval(<<'.,.,', 'parser.y', 348)
|
|
1742
1742
|
|
1743
1743
|
module_eval(<<'.,.,', 'parser.y', 353)
|
1744
1744
|
def _reduce_150(val, _values, result)
|
1745
|
-
return make_node(:ObjectTypeDefinition, name: val[2], interfaces: val[3], directives: val[4], fields: val[6], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
1745
|
+
return make_node(:ObjectTypeDefinition, name: val[2], interfaces: val[3], directives: val[4], fields: val[6], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
1746
1746
|
|
1747
1747
|
result
|
1748
1748
|
end
|
@@ -1808,7 +1808,7 @@ module_eval(<<'.,.,', 'parser.y', 371)
|
|
1808
1808
|
|
1809
1809
|
module_eval(<<'.,.,', 'parser.y', 375)
|
1810
1810
|
def _reduce_160(val, _values, result)
|
1811
|
-
return make_node(:InputValueDefinition, name: val[1], type: val[3], default_value: val[4], directives: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
1811
|
+
return make_node(:InputValueDefinition, name: val[1], type: val[3], default_value: val[4], directives: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
1812
1812
|
|
1813
1813
|
result
|
1814
1814
|
end
|
@@ -1844,7 +1844,7 @@ module_eval(<<'.,.,', 'parser.y', 384)
|
|
1844
1844
|
|
1845
1845
|
module_eval(<<'.,.,', 'parser.y', 388)
|
1846
1846
|
def _reduce_165(val, _values, result)
|
1847
|
-
return make_node(:FieldDefinition, name: val[1], arguments: val[2], type: val[4], directives: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
1847
|
+
return make_node(:FieldDefinition, name: val[1], arguments: val[2], type: val[4], directives: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
1848
1848
|
|
1849
1849
|
result
|
1850
1850
|
end
|
@@ -1873,7 +1873,7 @@ module_eval(<<'.,.,', 'parser.y', 394)
|
|
1873
1873
|
|
1874
1874
|
module_eval(<<'.,.,', 'parser.y', 398)
|
1875
1875
|
def _reduce_169(val, _values, result)
|
1876
|
-
return make_node(:InterfaceTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
1876
|
+
return make_node(:InterfaceTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
1877
1877
|
|
1878
1878
|
result
|
1879
1879
|
end
|
@@ -1895,7 +1895,7 @@ module_eval(<<'.,.,', 'parser.y', 403)
|
|
1895
1895
|
|
1896
1896
|
module_eval(<<'.,.,', 'parser.y', 407)
|
1897
1897
|
def _reduce_172(val, _values, result)
|
1898
|
-
return make_node(:UnionTypeDefinition, name: val[2], directives: val[3], types: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
1898
|
+
return make_node(:UnionTypeDefinition, name: val[2], directives: val[3], types: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
1899
1899
|
|
1900
1900
|
result
|
1901
1901
|
end
|
@@ -1903,7 +1903,7 @@ module_eval(<<'.,.,', 'parser.y', 407)
|
|
1903
1903
|
|
1904
1904
|
module_eval(<<'.,.,', 'parser.y', 412)
|
1905
1905
|
def _reduce_173(val, _values, result)
|
1906
|
-
return make_node(:EnumTypeDefinition, name: val[2], directives: val[3], values: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
1906
|
+
return make_node(:EnumTypeDefinition, name: val[2], directives: val[3], values: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
1907
1907
|
|
1908
1908
|
result
|
1909
1909
|
end
|
@@ -1911,7 +1911,7 @@ module_eval(<<'.,.,', 'parser.y', 412)
|
|
1911
1911
|
|
1912
1912
|
module_eval(<<'.,.,', 'parser.y', 417)
|
1913
1913
|
def _reduce_174(val, _values, result)
|
1914
|
-
return make_node(:InputObjectTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
1914
|
+
return make_node(:InputObjectTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
1915
1915
|
|
1916
1916
|
result
|
1917
1917
|
end
|
@@ -1919,7 +1919,7 @@ module_eval(<<'.,.,', 'parser.y', 417)
|
|
1919
1919
|
|
1920
1920
|
module_eval(<<'.,.,', 'parser.y', 422)
|
1921
1921
|
def _reduce_175(val, _values, result)
|
1922
|
-
return make_node(:DirectiveDefinition, name: val[3], arguments: val[4], locations: val[6], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
1922
|
+
return make_node(:DirectiveDefinition, name: val[3], arguments: val[4], locations: val[6], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
1923
1923
|
|
1924
1924
|
result
|
1925
1925
|
end
|
@@ -157,7 +157,7 @@ rule
|
|
157
157
|
| schema_keyword
|
158
158
|
|
159
159
|
enum_value_definition:
|
160
|
-
description_opt enum_name directives_list_opt { return make_node(:EnumValueDefinition, name: val[1], directives: val[2], description: val[0] || get_description(val[1]), position_source: val[0] || val[1]) }
|
160
|
+
description_opt enum_name directives_list_opt { return make_node(:EnumValueDefinition, name: val[1], directives: val[2], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1]) }
|
161
161
|
|
162
162
|
enum_value_definitions:
|
163
163
|
enum_value_definition { return [val[0]] }
|
@@ -280,7 +280,7 @@ rule
|
|
280
280
|
| directive_definition
|
281
281
|
|
282
282
|
schema_definition:
|
283
|
-
SCHEMA directives_list_opt LCURLY operation_type_definition_list RCURLY { return make_node(:SchemaDefinition, position_source: val[0], directives: val[1], **val[3]) }
|
283
|
+
SCHEMA directives_list_opt LCURLY operation_type_definition_list RCURLY { return make_node(:SchemaDefinition, position_source: val[0], definition_line: val[0].line, directives: val[1], **val[3]) }
|
284
284
|
|
285
285
|
operation_type_definition_list:
|
286
286
|
operation_type_definition
|
@@ -346,12 +346,12 @@ rule
|
|
346
346
|
|
347
347
|
scalar_type_definition:
|
348
348
|
description_opt SCALAR name directives_list_opt {
|
349
|
-
return make_node(:ScalarTypeDefinition, name: val[2], directives: val[3], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
349
|
+
return make_node(:ScalarTypeDefinition, name: val[2], directives: val[3], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
350
350
|
}
|
351
351
|
|
352
352
|
object_type_definition:
|
353
353
|
description_opt TYPE name implements_opt directives_list_opt LCURLY field_definition_list RCURLY {
|
354
|
-
return make_node(:ObjectTypeDefinition, name: val[2], interfaces: val[3], directives: val[4], fields: val[6], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
354
|
+
return make_node(:ObjectTypeDefinition, name: val[2], interfaces: val[3], directives: val[4], fields: val[6], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
355
355
|
}
|
356
356
|
|
357
357
|
implements_opt:
|
@@ -373,7 +373,7 @@ rule
|
|
373
373
|
|
374
374
|
input_value_definition:
|
375
375
|
description_opt name COLON type default_value_opt directives_list_opt {
|
376
|
-
return make_node(:InputValueDefinition, name: val[1], type: val[3], default_value: val[4], directives: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
376
|
+
return make_node(:InputValueDefinition, name: val[1], type: val[3], default_value: val[4], directives: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
377
377
|
}
|
378
378
|
|
379
379
|
input_value_definition_list:
|
@@ -386,7 +386,7 @@ rule
|
|
386
386
|
|
387
387
|
field_definition:
|
388
388
|
description_opt name arguments_definitions_opt COLON type directives_list_opt {
|
389
|
-
return make_node(:FieldDefinition, name: val[1], arguments: val[2], type: val[4], directives: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
389
|
+
return make_node(:FieldDefinition, name: val[1], arguments: val[2], type: val[4], directives: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
390
390
|
}
|
391
391
|
|
392
392
|
field_definition_list:
|
@@ -396,7 +396,7 @@ rule
|
|
396
396
|
|
397
397
|
interface_type_definition:
|
398
398
|
description_opt INTERFACE name directives_list_opt LCURLY field_definition_list RCURLY {
|
399
|
-
return make_node(:InterfaceTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
399
|
+
return make_node(:InterfaceTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
400
400
|
}
|
401
401
|
|
402
402
|
union_members:
|
@@ -405,22 +405,22 @@ rule
|
|
405
405
|
|
406
406
|
union_type_definition:
|
407
407
|
description_opt UNION name directives_list_opt EQUALS union_members {
|
408
|
-
return make_node(:UnionTypeDefinition, name: val[2], directives: val[3], types: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
408
|
+
return make_node(:UnionTypeDefinition, name: val[2], directives: val[3], types: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
409
409
|
}
|
410
410
|
|
411
411
|
enum_type_definition:
|
412
412
|
description_opt ENUM name directives_list_opt LCURLY enum_value_definitions RCURLY {
|
413
|
-
return make_node(:EnumTypeDefinition, name: val[2], directives: val[3], values: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
413
|
+
return make_node(:EnumTypeDefinition, name: val[2], directives: val[3], values: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
414
414
|
}
|
415
415
|
|
416
416
|
input_object_type_definition:
|
417
417
|
description_opt INPUT name directives_list_opt LCURLY input_value_definition_list RCURLY {
|
418
|
-
return make_node(:InputObjectTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
418
|
+
return make_node(:InputObjectTypeDefinition, name: val[2], directives: val[3], fields: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
419
419
|
}
|
420
420
|
|
421
421
|
directive_definition:
|
422
422
|
description_opt DIRECTIVE DIR_SIGN name arguments_definitions_opt ON directive_locations {
|
423
|
-
return make_node(:DirectiveDefinition, name: val[3], arguments: val[4], locations: val[6], description: val[0] || get_description(val[1]), position_source: val[0] || val[1])
|
423
|
+
return make_node(:DirectiveDefinition, name: val[3], arguments: val[4], locations: val[6], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
424
424
|
}
|
425
425
|
|
426
426
|
directive_locations:
|
@@ -447,7 +447,7 @@ def parse_document
|
|
447
447
|
end
|
448
448
|
# From the tokens, build an AST
|
449
449
|
@tracer.trace("parse", {query_string: @query_string}) do
|
450
|
-
if @tokens.
|
450
|
+
if @tokens.empty?
|
451
451
|
make_node(:Document, definitions: [], filename: @filename)
|
452
452
|
else
|
453
453
|
do_parse
|
@@ -135,7 +135,7 @@ module GraphQL
|
|
135
135
|
if (schema.query.nil? || schema.query == 'Query') &&
|
136
136
|
(schema.mutation.nil? || schema.mutation == 'Mutation') &&
|
137
137
|
(schema.subscription.nil? || schema.subscription == 'Subscription') &&
|
138
|
-
(schema.directives.
|
138
|
+
(schema.directives.empty?)
|
139
139
|
return
|
140
140
|
end
|
141
141
|
|
@@ -254,7 +254,7 @@ module GraphQL
|
|
254
254
|
return ''.dup unless node.description
|
255
255
|
|
256
256
|
description = indent != '' && !first_in_block ? "\n".dup : "".dup
|
257
|
-
description << GraphQL::Language::
|
257
|
+
description << GraphQL::Language::BlockString.print(node.description, indent: indent)
|
258
258
|
end
|
259
259
|
|
260
260
|
def print_field_definitions(fields)
|
@@ -3,32 +3,61 @@ module GraphQL
|
|
3
3
|
module Language
|
4
4
|
# Depth-first traversal through the tree, calling hooks at each stop.
|
5
5
|
#
|
6
|
-
# @example Create a visitor
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
6
|
+
# @example Create a visitor counting certain field names
|
7
|
+
# class NameCounter < GraphQL::Language::Visitor
|
8
|
+
# def initialize(document, field_name)
|
9
|
+
# super(document)
|
10
|
+
# @field_name
|
11
|
+
# @count = 0
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# attr_reader :count
|
15
|
+
#
|
16
|
+
# def on_field(node, parent)
|
17
|
+
# # if this field matches our search, increment the counter
|
18
|
+
# if node.name == @field_name
|
19
|
+
# @count = 0
|
20
|
+
# end
|
21
|
+
# # Continue visiting subfields:
|
22
|
+
# super
|
23
|
+
# end
|
24
|
+
# end
|
15
25
|
#
|
26
|
+
# # Initialize a visitor
|
27
|
+
# visitor = GraphQL::Language::Visitor.new(document, "name")
|
28
|
+
# # Run it
|
29
|
+
# visitor.visit
|
30
|
+
# # Check the result
|
31
|
+
# visitor.count
|
32
|
+
# # => 3
|
16
33
|
class Visitor
|
17
34
|
# If any hook returns this value, the {Visitor} stops visiting this
|
18
35
|
# node right away
|
36
|
+
# @deprecated Use `super` to continue the visit; or don't call it to halt.
|
19
37
|
SKIP = :_skip
|
20
38
|
|
39
|
+
class DeleteNode; end
|
40
|
+
|
41
|
+
# When this is returned from a visitor method,
|
42
|
+
# Then the `node` passed into the method is removed from `parent`'s children.
|
43
|
+
DELETE_NODE = DeleteNode.new
|
44
|
+
|
21
45
|
def initialize(document)
|
22
46
|
@document = document
|
23
47
|
@visitors = {}
|
48
|
+
@result = nil
|
24
49
|
end
|
25
50
|
|
51
|
+
# @return [GraphQL::Language::Nodes::Document] The document with any modifications applied
|
52
|
+
attr_reader :result
|
53
|
+
|
26
54
|
# Get a {NodeVisitor} for `node_class`
|
27
55
|
# @param node_class [Class] The node class that you want to listen to
|
28
56
|
# @return [NodeVisitor]
|
29
57
|
#
|
30
58
|
# @example Run a hook whenever you enter a new Field
|
31
59
|
# visitor[GraphQL::Language::Nodes::Field] << ->(node, parent) { p "Here's a field" }
|
60
|
+
# @deprecated see `on_` methods, like {#on_field}
|
32
61
|
def [](node_class)
|
33
62
|
@visitors[node_class] ||= NodeVisitor.new
|
34
63
|
end
|
@@ -36,17 +65,131 @@ module GraphQL
|
|
36
65
|
# Visit `document` and all children, applying hooks as you go
|
37
66
|
# @return [void]
|
38
67
|
def visit
|
39
|
-
|
68
|
+
result = on_node_with_modifications(@document, nil)
|
69
|
+
@result = if result.is_a?(Array)
|
70
|
+
result.first
|
71
|
+
else
|
72
|
+
# The node wasn't modified
|
73
|
+
@document
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Call the user-defined handler for `node`.
|
78
|
+
def visit_node(node, parent)
|
79
|
+
public_send(node.visit_method, node, parent)
|
80
|
+
end
|
81
|
+
|
82
|
+
# The default implementation for visiting an AST node.
|
83
|
+
# It doesn't _do_ anything, but it continues to visiting the node's children.
|
84
|
+
# To customize this hook, override one of its make_visit_methodes (or the base method?)
|
85
|
+
# in your subclasses.
|
86
|
+
#
|
87
|
+
# For compatibility, it calls hook procs, too.
|
88
|
+
# @param node [GraphQL::Language::Nodes::AbstractNode] the node being visited
|
89
|
+
# @param parent [GraphQL::Language::Nodes::AbstractNode, nil] the previously-visited node, or `nil` if this is the root node.
|
90
|
+
# @return [Array, nil] If there were modifications, it returns an array of new nodes, otherwise, it returns `nil`.
|
91
|
+
def on_abstract_node(node, parent)
|
92
|
+
if node == DELETE_NODE
|
93
|
+
# This might be passed to `super(DELETE_NODE, ...)`
|
94
|
+
# by a user hook, don't want to keep visiting in that case.
|
95
|
+
nil
|
96
|
+
else
|
97
|
+
# Run hooks if there are any
|
98
|
+
new_node = node
|
99
|
+
begin_hooks_ok = @visitors.empty? || begin_visit(new_node, parent)
|
100
|
+
if begin_hooks_ok
|
101
|
+
node.children.each do |child_node|
|
102
|
+
new_child_and_node = on_node_with_modifications(child_node, new_node)
|
103
|
+
# Reassign `node` in case the child hook makes a modification
|
104
|
+
if new_child_and_node.is_a?(Array)
|
105
|
+
new_node = new_child_and_node[1]
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
@visitors.any? && end_visit(new_node, parent)
|
110
|
+
|
111
|
+
if new_node.equal?(node)
|
112
|
+
nil
|
113
|
+
else
|
114
|
+
[new_node, parent]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# We don't use `alias` here because it breaks `super`
|
120
|
+
def self.make_visit_method(node_method)
|
121
|
+
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
122
|
+
def #{node_method}(node, parent)
|
123
|
+
child_mod = on_abstract_node(node, parent)
|
124
|
+
# If visiting the children returned changes, continue passing those.
|
125
|
+
child_mod || [node, parent]
|
126
|
+
end
|
127
|
+
RUBY
|
40
128
|
end
|
41
129
|
|
130
|
+
make_visit_method :on_argument
|
131
|
+
make_visit_method :on_directive
|
132
|
+
make_visit_method :on_directive_definition
|
133
|
+
make_visit_method :on_directive_location
|
134
|
+
make_visit_method :on_document
|
135
|
+
make_visit_method :on_enum
|
136
|
+
make_visit_method :on_enum_type_definition
|
137
|
+
make_visit_method :on_enum_type_extension
|
138
|
+
make_visit_method :on_enum_value_definition
|
139
|
+
make_visit_method :on_field
|
140
|
+
make_visit_method :on_field_definition
|
141
|
+
make_visit_method :on_fragment_definition
|
142
|
+
make_visit_method :on_fragment_spread
|
143
|
+
make_visit_method :on_inline_fragment
|
144
|
+
make_visit_method :on_input_object
|
145
|
+
make_visit_method :on_input_object_type_definition
|
146
|
+
make_visit_method :on_input_object_type_extension
|
147
|
+
make_visit_method :on_input_value_definition
|
148
|
+
make_visit_method :on_interface_type_definition
|
149
|
+
make_visit_method :on_interface_type_extension
|
150
|
+
make_visit_method :on_list_type
|
151
|
+
make_visit_method :on_non_null_type
|
152
|
+
make_visit_method :on_null_value
|
153
|
+
make_visit_method :on_object_type_definition
|
154
|
+
make_visit_method :on_object_type_extension
|
155
|
+
make_visit_method :on_operation_definition
|
156
|
+
make_visit_method :on_scalar_type_definition
|
157
|
+
make_visit_method :on_scalar_type_extension
|
158
|
+
make_visit_method :on_schema_definition
|
159
|
+
make_visit_method :on_schema_extension
|
160
|
+
make_visit_method :on_type_name
|
161
|
+
make_visit_method :on_union_type_definition
|
162
|
+
make_visit_method :on_union_type_extension
|
163
|
+
make_visit_method :on_variable_definition
|
164
|
+
make_visit_method :on_variable_identifier
|
165
|
+
|
42
166
|
private
|
43
167
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
168
|
+
# Run the hooks for `node`, and if the hooks return a copy of `node`,
|
169
|
+
# copy `parent` so that it contains the copy of that node as a child,
|
170
|
+
# then return the copies
|
171
|
+
def on_node_with_modifications(node, parent)
|
172
|
+
new_node_and_new_parent = visit_node(node, parent)
|
173
|
+
if new_node_and_new_parent.is_a?(Array)
|
174
|
+
new_node = new_node_and_new_parent[0]
|
175
|
+
new_parent = new_node_and_new_parent[1]
|
176
|
+
if new_node.is_a?(Nodes::AbstractNode) && !node.equal?(new_node)
|
177
|
+
# The user-provided hook returned a new node.
|
178
|
+
new_parent = new_parent && new_parent.replace_child(node, new_node)
|
179
|
+
return new_node, new_parent
|
180
|
+
elsif new_node == DELETE_NODE
|
181
|
+
# The user-provided hook requested to remove this node
|
182
|
+
new_parent = new_parent && new_parent.delete_child(node)
|
183
|
+
return nil, new_parent
|
184
|
+
else
|
185
|
+
new_node_and_new_parent
|
186
|
+
end
|
187
|
+
else
|
188
|
+
# The user-provided hook didn't make any modifications.
|
189
|
+
# In fact, the hook might have returned who-knows-what, so
|
190
|
+
# ignore the return value and use the original values.
|
191
|
+
new_node_and_new_parent
|
48
192
|
end
|
49
|
-
end_visit(node, parent)
|
50
193
|
end
|
51
194
|
|
52
195
|
def begin_visit(node, parent)
|
data/lib/graphql/language.rb
CHANGED
@@ -6,6 +6,7 @@ module GraphQL
|
|
6
6
|
# {Arguments} recursively wraps the input in {Arguments} instances.
|
7
7
|
class Arguments
|
8
8
|
extend Forwardable
|
9
|
+
include GraphQL::Dig
|
9
10
|
|
10
11
|
def self.construct_arguments_class(argument_owner)
|
11
12
|
argument_definitions = argument_owner.arguments
|
@@ -40,7 +41,7 @@ module GraphQL
|
|
40
41
|
def initialize(values, context:, defaults_used:)
|
41
42
|
@argument_values = values.inject({}) do |memo, (inner_key, inner_value)|
|
42
43
|
arg_name = inner_key.to_s
|
43
|
-
arg_defn = self.class.argument_definitions[arg_name]
|
44
|
+
arg_defn = self.class.argument_definitions[arg_name] || raise("Not found #{arg_name} among #{self.class.argument_definitions.keys}")
|
44
45
|
arg_default_used = defaults_used.include?(arg_name)
|
45
46
|
arg_value = wrap_value(inner_value, arg_defn.type, context)
|
46
47
|
string_key = arg_defn.expose_as
|
@@ -167,7 +168,7 @@ module GraphQL
|
|
167
168
|
memo[key] = unwrap_value(value)
|
168
169
|
memo
|
169
170
|
end
|
170
|
-
when GraphQL::Query::Arguments
|
171
|
+
when GraphQL::Query::Arguments, GraphQL::Schema::InputObject
|
171
172
|
value.to_h
|
172
173
|
else
|
173
174
|
value
|
@@ -8,7 +8,7 @@ module GraphQL
|
|
8
8
|
Hash.new do |h1, irep_or_ast_node|
|
9
9
|
h1[irep_or_ast_node] = Hash.new do |h2, definition|
|
10
10
|
ast_node = irep_or_ast_node.is_a?(GraphQL::InternalRepresentation::Node) ? irep_or_ast_node.ast_node : irep_or_ast_node
|
11
|
-
h2[definition] = if definition.arguments.
|
11
|
+
h2[definition] = if definition.arguments.empty?
|
12
12
|
GraphQL::Query::Arguments::NO_ARGS
|
13
13
|
else
|
14
14
|
GraphQL::Query::LiteralInput.from_arguments(
|
@@ -7,7 +7,7 @@ module GraphQL
|
|
7
7
|
# It delegates `[]` to the hash that's passed to `GraphQL::Query#initialize`.
|
8
8
|
class Context
|
9
9
|
module SharedMethods
|
10
|
-
# @return [Object] The target for field
|
10
|
+
# @return [Object] The target for field resolution
|
11
11
|
attr_accessor :object
|
12
12
|
|
13
13
|
# @return [Hash, Array, String, Integer, Float, Boolean, nil] The resolved value for this field
|
@@ -74,6 +74,12 @@ module GraphQL
|
|
74
74
|
def execution_errors
|
75
75
|
@execution_errors ||= ExecutionErrors.new(self)
|
76
76
|
end
|
77
|
+
|
78
|
+
def lookahead
|
79
|
+
ast_nodes = irep_node.ast_nodes
|
80
|
+
field = irep_node.definition.metadata[:type_class] || raise("Lookahead is only compatible with class-based schemas")
|
81
|
+
Execution::Lookahead.new(query: query, ast_nodes: ast_nodes, field: field)
|
82
|
+
end
|
77
83
|
end
|
78
84
|
|
79
85
|
class ExecutionErrors
|
@@ -151,11 +157,14 @@ module GraphQL
|
|
151
157
|
@context = self # for SharedMethods
|
152
158
|
end
|
153
159
|
|
160
|
+
# @api private
|
161
|
+
attr_writer :interpreter
|
162
|
+
|
154
163
|
# @api private
|
155
164
|
attr_writer :value
|
156
165
|
|
157
|
-
def_delegators :@provided_values, :[], :[]=, :to_h, :key?, :fetch
|
158
|
-
def_delegators :@query, :trace
|
166
|
+
def_delegators :@provided_values, :[], :[]=, :to_h, :to_hash, :key?, :fetch, :dig
|
167
|
+
def_delegators :@query, :trace, :interpreter?
|
159
168
|
|
160
169
|
# @!method [](key)
|
161
170
|
# Lookup `key` from the hash passed to {Schema#execute} as `context:`
|
@@ -220,9 +229,9 @@ module GraphQL
|
|
220
229
|
end
|
221
230
|
|
222
231
|
def_delegators :@context,
|
223
|
-
:[], :[]=, :key?, :fetch, :to_h, :namespace,
|
232
|
+
:[], :[]=, :key?, :fetch, :to_h, :namespace, :dig,
|
224
233
|
:spawn, :warden, :errors,
|
225
|
-
:execution_strategy, :strategy
|
234
|
+
:execution_strategy, :strategy, :interpreter?
|
226
235
|
|
227
236
|
# @return [GraphQL::Language::Nodes::Field] The AST node for the currently-executing field
|
228
237
|
def ast_node
|
@@ -12,7 +12,7 @@ module GraphQL
|
|
12
12
|
@query = query
|
13
13
|
end
|
14
14
|
|
15
|
-
#
|
15
|
+
# Evaluate {operation_name} on {query}.
|
16
16
|
# Handle {GraphQL::ExecutionError}s by putting them in the "errors" key.
|
17
17
|
# @return [Hash] A GraphQL response, with either a "data" key or an "errors" key
|
18
18
|
def result
|