graphql 1.8.7 → 1.9.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.
- 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
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# helpers to enable / disable error bubbling in a block scope
|
3
|
+
module ErrorBubblingHelpers
|
4
|
+
def without_error_bubbling(schema)
|
5
|
+
original_error_bubbling = schema.error_bubbling
|
6
|
+
begin
|
7
|
+
schema.error_bubbling = false
|
8
|
+
yield if block_given?
|
9
|
+
ensure
|
10
|
+
schema.error_bubbling = original_error_bubbling
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def with_error_bubbling(schema)
|
15
|
+
original_error_bubbling = schema.error_bubbling
|
16
|
+
begin
|
17
|
+
schema.error_bubbling = true
|
18
|
+
yield if block_given?
|
19
|
+
ensure
|
20
|
+
schema.error_bubbling = original_error_bubbling
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/support/jazz.rb
CHANGED
@@ -9,7 +9,7 @@ module Jazz
|
|
9
9
|
Key = Struct.new(:root, :sharp, :flat) do
|
10
10
|
def self.from_notation(key_str)
|
11
11
|
key, sharp_or_flat = key_str.split("")
|
12
|
-
sharp = sharp_or_flat ==
|
12
|
+
sharp = sharp_or_flat == "♯"
|
13
13
|
flat = sharp_or_flat == "♭"
|
14
14
|
Models::Key.new(key, sharp, flat)
|
15
15
|
end
|
@@ -36,7 +36,7 @@ module Jazz
|
|
36
36
|
],
|
37
37
|
"Musician" => [
|
38
38
|
Models::Musician.new("Herbie Hancock", Models::Key.from_notation("B♭")),
|
39
|
-
]
|
39
|
+
],
|
40
40
|
}
|
41
41
|
end
|
42
42
|
|
@@ -61,6 +61,8 @@ module Jazz
|
|
61
61
|
# A custom field class that supports the `upcase:` option
|
62
62
|
class BaseField < GraphQL::Schema::Field
|
63
63
|
argument_class BaseArgument
|
64
|
+
attr_reader :upcase
|
65
|
+
|
64
66
|
def initialize(*args, **options, &block)
|
65
67
|
@upcase = options.delete(:upcase)
|
66
68
|
super(*args, **options, &block)
|
@@ -74,6 +76,15 @@ module Jazz
|
|
74
76
|
result
|
75
77
|
end
|
76
78
|
end
|
79
|
+
|
80
|
+
def resolve(*)
|
81
|
+
result = super
|
82
|
+
if @upcase && result
|
83
|
+
result.upcase
|
84
|
+
else
|
85
|
+
result
|
86
|
+
end
|
87
|
+
end
|
77
88
|
end
|
78
89
|
|
79
90
|
class BaseObject < GraphQL::Schema::Object
|
@@ -91,7 +102,7 @@ module Jazz
|
|
91
102
|
|
92
103
|
def to_graphql
|
93
104
|
type_defn = super
|
94
|
-
configs.each do |k,v|
|
105
|
+
configs.each do |k, v|
|
95
106
|
type_defn.metadata[k] = v
|
96
107
|
end
|
97
108
|
type_defn
|
@@ -140,7 +151,7 @@ module Jazz
|
|
140
151
|
null: false,
|
141
152
|
description: "A unique identifier for this object",
|
142
153
|
)
|
143
|
-
upcased_field :upcased_id, ID, null: false,
|
154
|
+
upcased_field :upcased_id, ID, null: false, resolver_method: :id # upcase: true added by helper
|
144
155
|
|
145
156
|
def id
|
146
157
|
GloballyIdentifiableType.to_id(@object)
|
@@ -156,10 +167,9 @@ module Jazz
|
|
156
167
|
end
|
157
168
|
end
|
158
169
|
|
159
|
-
|
160
|
-
|
161
|
-
name
|
162
|
-
field :name, !types.String
|
170
|
+
module NamedEntity
|
171
|
+
include BaseInterface
|
172
|
+
field :name, String, null: false
|
163
173
|
end
|
164
174
|
|
165
175
|
# test field inheritance
|
@@ -177,12 +187,11 @@ module Jazz
|
|
177
187
|
field :musicians, "[Jazz::Musician]", null: false
|
178
188
|
end
|
179
189
|
|
180
|
-
|
181
190
|
# Here's a new-style GraphQL type definition
|
182
191
|
class Ensemble < ObjectWithUpcasedName
|
183
192
|
# Test string type names
|
184
193
|
# This method should override inherited one
|
185
|
-
field :name, "String", null: false,
|
194
|
+
field :name, "String", null: false, resolver_method: :overridden_name
|
186
195
|
implements GloballyIdentifiableType, NamedEntity, HasMusicians
|
187
196
|
description "A group of musicians playing together"
|
188
197
|
config :config, :configged
|
@@ -210,23 +219,23 @@ module Jazz
|
|
210
219
|
value "KEYS" do
|
211
220
|
description "Neither here nor there, really"
|
212
221
|
end
|
222
|
+
value "SILENCE", "Makes no sound", value: false
|
213
223
|
end
|
214
224
|
|
215
225
|
# Lives side-by-side with an old-style definition
|
216
226
|
using GraphQL::DeprecatedDSL # for ! and types[]
|
217
|
-
|
218
|
-
|
219
|
-
|
227
|
+
|
228
|
+
class InstrumentType < BaseObject
|
229
|
+
implements NamedEntity
|
220
230
|
implements GloballyIdentifiableType
|
221
231
|
|
222
|
-
field :
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
field :family, Family.to_non_null_type
|
227
|
-
else
|
228
|
-
field :family, !Family
|
232
|
+
field :upcased_id, ID, null: false
|
233
|
+
|
234
|
+
def upcased_id
|
235
|
+
GloballyIdentifiableType.to_id(object).upcase
|
229
236
|
end
|
237
|
+
|
238
|
+
field :family, Family, null: false
|
230
239
|
end
|
231
240
|
|
232
241
|
class Key < GraphQL::Schema::Scalar
|
@@ -261,6 +270,7 @@ module Jazz
|
|
261
270
|
# Test lists with nullable members:
|
262
271
|
field :inspect_context, [String, null: true], null: false
|
263
272
|
field :add_error, String, null: false, extras: [:execution_errors]
|
273
|
+
|
264
274
|
def inspect_context
|
265
275
|
[
|
266
276
|
@context.custom_method,
|
@@ -276,21 +286,22 @@ module Jazz
|
|
276
286
|
end
|
277
287
|
end
|
278
288
|
|
279
|
-
|
280
|
-
|
281
|
-
argument :
|
289
|
+
# Since this is not a legacy input type, this test can be removed
|
290
|
+
class LegacyInputType < GraphQL::Schema::InputObject
|
291
|
+
argument :int_value, Int, required: true
|
282
292
|
end
|
283
293
|
|
284
294
|
class InspectableInput < GraphQL::Schema::InputObject
|
285
295
|
argument :string_value, String, required: true, description: "Test description kwarg"
|
286
296
|
argument :nested_input, InspectableInput, required: false
|
287
297
|
argument :legacy_input, LegacyInputType, required: false
|
298
|
+
|
288
299
|
def helper_method
|
289
300
|
[
|
290
301
|
# Context is available in the InputObject
|
291
302
|
context[:message],
|
292
|
-
# A GraphQL::Query::Arguments instance is available
|
293
|
-
|
303
|
+
# ~~A GraphQL::Query::Arguments instance is available~~ not anymore
|
304
|
+
self[:string_value],
|
294
305
|
# Legacy inputs have underscored method access too
|
295
306
|
legacy_input ? legacy_input.int_value : "-",
|
296
307
|
# Access by method call is available
|
@@ -309,10 +320,12 @@ module Jazz
|
|
309
320
|
possible_types Musician, Ensemble
|
310
321
|
|
311
322
|
def self.resolve_type(object, context)
|
312
|
-
|
313
|
-
Ensemble
|
314
|
-
|
315
|
-
|
323
|
+
GraphQL::Execution::Lazy.new do
|
324
|
+
if object.is_a?(Models::Ensemble)
|
325
|
+
Ensemble
|
326
|
+
else
|
327
|
+
Musician
|
328
|
+
end
|
316
329
|
end
|
317
330
|
end
|
318
331
|
end
|
@@ -336,9 +349,12 @@ module Jazz
|
|
336
349
|
field :inspect_key, InspectableKey, null: false do
|
337
350
|
argument :key, Key, required: true
|
338
351
|
end
|
339
|
-
field :
|
352
|
+
field :now_playing, PerformingAct, null: false
|
353
|
+
|
354
|
+
def now_playing; Models.data["Ensemble"].first; end
|
355
|
+
|
340
356
|
# For asserting that the object is initialized once:
|
341
|
-
field :object_id,
|
357
|
+
field :object_id, String, null: false
|
342
358
|
field :inspect_context, [String], null: false
|
343
359
|
field :hashyEnsemble, Ensemble, null: false
|
344
360
|
|
@@ -350,6 +366,14 @@ module Jazz
|
|
350
366
|
argument :input, [RawJson], required: true
|
351
367
|
end
|
352
368
|
|
369
|
+
field :upcase_check_1, String, null: true, resolver_method: :upcase_check, extras: [:upcase]
|
370
|
+
field :upcase_check_2, String, null: false, upcase: false, resolver_method: :upcase_check, extras: [:upcase]
|
371
|
+
field :upcase_check_3, String, null: false, upcase: true, resolver_method: :upcase_check, extras: [:upcase]
|
372
|
+
field :upcase_check_4, String, null: false, upcase: "why not?", resolver_method: :upcase_check, extras: [:upcase]
|
373
|
+
def upcase_check(upcase:)
|
374
|
+
upcase.inspect
|
375
|
+
end
|
376
|
+
|
353
377
|
def ensembles
|
354
378
|
# Filter out the unauthorized one to avoid an error later
|
355
379
|
Models.data["Ensemble"].select { |e| e.name != "Spinal Tap" }
|
@@ -381,8 +405,8 @@ module Jazz
|
|
381
405
|
# Access by key:
|
382
406
|
input[:string_value],
|
383
407
|
input.key?(:string_value).to_s,
|
384
|
-
# Access by legacy key
|
385
|
-
input[:
|
408
|
+
# ~~Access by legacy key~~ # not anymore
|
409
|
+
input[:string_value],
|
386
410
|
]
|
387
411
|
end
|
388
412
|
|
@@ -394,7 +418,7 @@ module Jazz
|
|
394
418
|
[
|
395
419
|
context.custom_method,
|
396
420
|
context[:magic_key],
|
397
|
-
context[:normal_key]
|
421
|
+
context[:normal_key],
|
398
422
|
]
|
399
423
|
end
|
400
424
|
|
@@ -402,11 +426,11 @@ module Jazz
|
|
402
426
|
# Both string and symbol keys are supported:
|
403
427
|
|
404
428
|
{
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
429
|
+
name: "The Grateful Dead",
|
430
|
+
"musicians" => [
|
431
|
+
OpenStruct.new(name: "Jerry Garcia"),
|
432
|
+
],
|
433
|
+
"formedAtDate" => "May 5, 1965",
|
410
434
|
}
|
411
435
|
end
|
412
436
|
|
@@ -420,12 +444,13 @@ module Jazz
|
|
420
444
|
|
421
445
|
field :hash_by_string, HashKeyTest, null: false
|
422
446
|
field :hash_by_sym, HashKeyTest, null: false
|
447
|
+
|
423
448
|
def hash_by_string
|
424
|
-
{
|
449
|
+
{"falsey" => false}
|
425
450
|
end
|
426
451
|
|
427
452
|
def hash_by_sym
|
428
|
-
{
|
453
|
+
{falsey: false}
|
429
454
|
end
|
430
455
|
|
431
456
|
field :named_entities, [NamedEntity, null: true], null: false
|
@@ -433,6 +458,20 @@ module Jazz
|
|
433
458
|
def named_entities
|
434
459
|
[Models.data["Ensemble"].first, nil]
|
435
460
|
end
|
461
|
+
|
462
|
+
field :default_value_test, String, null: false do
|
463
|
+
if TESTING_INTERPRETER
|
464
|
+
argument :arg_with_default, InspectableInput, required: false, default_value: { string_value: "S" }
|
465
|
+
else
|
466
|
+
argument :arg_with_default, InspectableInput, required: false, default_value: { "stringValue" => "S" }
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
def default_value_test(arg_with_default:)
|
471
|
+
"#{arg_with_default.class.name} -> #{arg_with_default.to_h}"
|
472
|
+
end
|
473
|
+
|
474
|
+
field :complex_hash_key, String, null: false, hash_key: :'foo bar/fizz-buzz'
|
436
475
|
end
|
437
476
|
|
438
477
|
class EnsembleInput < GraphQL::Schema::InputObject
|
@@ -453,10 +492,11 @@ module Jazz
|
|
453
492
|
|
454
493
|
field :ee, String, null: false
|
455
494
|
extras [:execution_errors]
|
495
|
+
|
456
496
|
def resolve(name:, family:, execution_errors:)
|
457
497
|
instrument = Jazz::Models::Instrument.new(name, family)
|
458
498
|
Jazz::Models.data["Instrument"] << instrument
|
459
|
-
{
|
499
|
+
{instrument: instrument, entries: Jazz::Models.data["Instrument"], ee: execution_errors.class.name}
|
460
500
|
end
|
461
501
|
end
|
462
502
|
|
@@ -468,7 +508,59 @@ module Jazz
|
|
468
508
|
|
469
509
|
def resolve
|
470
510
|
instrument = Models::Instrument.new("Sitar", :str)
|
471
|
-
{
|
511
|
+
{instrument: instrument}
|
512
|
+
end
|
513
|
+
end
|
514
|
+
|
515
|
+
class HasExtras < GraphQL::Schema::RelayClassicMutation
|
516
|
+
null true
|
517
|
+
description "Test extras in RelayClassicMutation"
|
518
|
+
|
519
|
+
argument :int, Integer, required: false
|
520
|
+
extras [:ast_node]
|
521
|
+
|
522
|
+
field :node_class, String, null: false
|
523
|
+
field :int, Integer, null: true
|
524
|
+
|
525
|
+
def resolve(int: nil, ast_node:)
|
526
|
+
{
|
527
|
+
int: int,
|
528
|
+
node_class: ast_node.class.name,
|
529
|
+
}
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
class RenameNamedEntity < GraphQL::Schema::RelayClassicMutation
|
534
|
+
argument :named_entity_id, ID, required: true, loads: NamedEntity
|
535
|
+
argument :new_name, String, required: true
|
536
|
+
|
537
|
+
field :named_entity, NamedEntity, null: false
|
538
|
+
|
539
|
+
def resolve(named_entity:, new_name:)
|
540
|
+
# doesn't actually update the "database"
|
541
|
+
dup_named_entity = named_entity.dup
|
542
|
+
dup_named_entity.name = new_name
|
543
|
+
|
544
|
+
{
|
545
|
+
named_entity: dup_named_entity
|
546
|
+
}
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
550
|
+
class RenamePerformingAct < GraphQL::Schema::RelayClassicMutation
|
551
|
+
argument :performing_act_id, ID, required: true, loads: PerformingAct
|
552
|
+
argument :new_name, String, required: true
|
553
|
+
|
554
|
+
field :performing_act, PerformingAct, null: false
|
555
|
+
|
556
|
+
def resolve(performing_act:, new_name:)
|
557
|
+
# doesn't actually update the "database"
|
558
|
+
dup_performing_act = performing_act.dup
|
559
|
+
dup_performing_act.name = new_name
|
560
|
+
|
561
|
+
{
|
562
|
+
performing_act: dup_performing_act
|
563
|
+
}
|
472
564
|
end
|
473
565
|
end
|
474
566
|
|
@@ -483,11 +575,55 @@ module Jazz
|
|
483
575
|
dup_ensemble = ensemble.dup
|
484
576
|
dup_ensemble.name = new_name
|
485
577
|
{
|
486
|
-
ensemble: dup_ensemble
|
578
|
+
ensemble: dup_ensemble,
|
579
|
+
}
|
580
|
+
end
|
581
|
+
end
|
582
|
+
|
583
|
+
class UpvoteEnsembles < GraphQL::Schema::RelayClassicMutation
|
584
|
+
argument :ensemble_ids, [ID], required: true, loads: Ensemble
|
585
|
+
|
586
|
+
field :ensembles, [Ensemble], null: false
|
587
|
+
|
588
|
+
def resolve(ensembles:)
|
589
|
+
{
|
590
|
+
ensembles: ensembles
|
591
|
+
}
|
592
|
+
end
|
593
|
+
end
|
594
|
+
|
595
|
+
class UpvoteEnsemblesAsBands < GraphQL::Schema::RelayClassicMutation
|
596
|
+
argument :ensemble_ids, [ID], required: true, loads: Ensemble, as: :bands
|
597
|
+
|
598
|
+
field :ensembles, [Ensemble], null: false
|
599
|
+
|
600
|
+
def resolve(bands:)
|
601
|
+
{
|
602
|
+
ensembles: bands
|
487
603
|
}
|
488
604
|
end
|
489
605
|
end
|
490
606
|
|
607
|
+
class UpvoteEnsemblesIds < GraphQL::Schema::RelayClassicMutation
|
608
|
+
argument :ensembles_ids, [ID], required: true, loads: Ensemble
|
609
|
+
|
610
|
+
field :ensembles, [Ensemble], null: false
|
611
|
+
|
612
|
+
def resolve(ensembles:)
|
613
|
+
{
|
614
|
+
ensembles: ensembles
|
615
|
+
}
|
616
|
+
end
|
617
|
+
end
|
618
|
+
|
619
|
+
class RenameEnsembleAsBand < RenameEnsemble
|
620
|
+
argument :ensemble_id, ID, required: true, loads: Ensemble, as: :band
|
621
|
+
|
622
|
+
def resolve(band:, new_name:)
|
623
|
+
super(ensemble: band, new_name: new_name)
|
624
|
+
end
|
625
|
+
end
|
626
|
+
|
491
627
|
class Mutation < BaseObject
|
492
628
|
field :add_ensemble, Ensemble, null: false do
|
493
629
|
argument :input, EnsembleInput, required: true
|
@@ -496,6 +632,13 @@ module Jazz
|
|
496
632
|
field :add_instrument, mutation: AddInstrument
|
497
633
|
field :add_sitar, mutation: AddSitar
|
498
634
|
field :rename_ensemble, mutation: RenameEnsemble
|
635
|
+
field :rename_named_entity, mutation: RenameNamedEntity
|
636
|
+
field :rename_performing_act, mutation: RenamePerformingAct
|
637
|
+
field :upvote_ensembles, mutation: UpvoteEnsembles
|
638
|
+
field :upvote_ensembles_as_bands, mutation: UpvoteEnsemblesAsBands
|
639
|
+
field :upvote_ensembles_ids, mutation: UpvoteEnsemblesIds
|
640
|
+
field :rename_ensemble_as_band, mutation: RenameEnsembleAsBand
|
641
|
+
field :has_extras, mutation: HasExtras
|
499
642
|
|
500
643
|
def add_ensemble(input:)
|
501
644
|
ens = Models::Ensemble.new(input.name)
|
@@ -539,15 +682,29 @@ module Jazz
|
|
539
682
|
|
540
683
|
module Introspection
|
541
684
|
class TypeType < GraphQL::Introspection::TypeType
|
685
|
+
def name
|
686
|
+
n = object.graphql_name
|
687
|
+
n && n.upcase
|
688
|
+
end
|
689
|
+
end
|
690
|
+
|
691
|
+
class NestedType < GraphQL::Introspection::TypeType
|
542
692
|
def name
|
543
693
|
object.name.upcase
|
544
694
|
end
|
695
|
+
|
696
|
+
class DeeplyNestedType < GraphQL::Introspection::TypeType
|
697
|
+
def name
|
698
|
+
object.name.upcase
|
699
|
+
end
|
700
|
+
end
|
545
701
|
end
|
546
702
|
|
547
703
|
class SchemaType < GraphQL::Introspection::SchemaType
|
548
704
|
graphql_name "__Schema"
|
549
705
|
|
550
706
|
field :is_jazzy, Boolean, null: false
|
707
|
+
|
551
708
|
def is_jazzy
|
552
709
|
true
|
553
710
|
end
|
@@ -556,7 +713,8 @@ module Jazz
|
|
556
713
|
class DynamicFields < GraphQL::Introspection::DynamicFields
|
557
714
|
field :__typename_length, Int, null: false, extras: [:irep_node]
|
558
715
|
field :__ast_node_class, String, null: false, extras: [:ast_node]
|
559
|
-
|
716
|
+
|
717
|
+
def __typename_length(irep_node: nil)
|
560
718
|
__typename(irep_node: irep_node).length
|
561
719
|
end
|
562
720
|
|
@@ -567,8 +725,13 @@ module Jazz
|
|
567
725
|
|
568
726
|
class EntryPoints < GraphQL::Introspection::EntryPoints
|
569
727
|
field :__classname, String, "The Ruby class name of the root object", null: false
|
728
|
+
|
570
729
|
def __classname
|
571
|
-
|
730
|
+
if context.interpreter?
|
731
|
+
object.object.class.name
|
732
|
+
else
|
733
|
+
object.class.name
|
734
|
+
end
|
572
735
|
end
|
573
736
|
end
|
574
737
|
end
|
@@ -588,5 +751,9 @@ module Jazz
|
|
588
751
|
def self.object_from_id(id, ctx)
|
589
752
|
GloballyIdentifiableType.find(id)
|
590
753
|
end
|
754
|
+
if TESTING_INTERPRETER
|
755
|
+
use GraphQL::Execution::Interpreter
|
756
|
+
use GraphQL::Analysis::AST
|
757
|
+
end
|
591
758
|
end
|
592
759
|
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module LazyHelpers
|
3
|
+
MAGIC_NUMBER_WITH_LAZY_AUTHORIZED_HOOK = 44
|
4
|
+
MAGIC_NUMBER_THAT_RETURNS_NIL = 0
|
5
|
+
MAGIC_NUMBER_THAT_RAISES_ERROR = 13
|
3
6
|
class Wrapper
|
4
7
|
def initialize(item = nil, &block)
|
5
8
|
if block
|
@@ -22,7 +25,7 @@ module LazyHelpers
|
|
22
25
|
attr_reader :own_value
|
23
26
|
attr_writer :value
|
24
27
|
|
25
|
-
def initialize(
|
28
|
+
def initialize(own_value)
|
26
29
|
@own_value = own_value
|
27
30
|
all << self
|
28
31
|
end
|
@@ -47,16 +50,32 @@ module LazyHelpers
|
|
47
50
|
end
|
48
51
|
|
49
52
|
class LazySum < GraphQL::Schema::Object
|
50
|
-
field :value, Integer, null: true
|
53
|
+
field :value, Integer, null: true
|
54
|
+
def value
|
55
|
+
if object == MAGIC_NUMBER_THAT_RAISES_ERROR
|
56
|
+
nil
|
57
|
+
else
|
58
|
+
object
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.authorized?(obj, ctx)
|
63
|
+
if obj == MAGIC_NUMBER_WITH_LAZY_AUTHORIZED_HOOK
|
64
|
+
Wrapper.new { true }
|
65
|
+
else
|
66
|
+
true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
51
70
|
field :nestedSum, LazySum, null: false do
|
52
71
|
argument :value, Integer, required: true
|
53
72
|
end
|
54
73
|
|
55
74
|
def nested_sum(value:)
|
56
|
-
if value ==
|
75
|
+
if value == MAGIC_NUMBER_THAT_RAISES_ERROR
|
57
76
|
Wrapper.new(nil)
|
58
77
|
else
|
59
|
-
SumAll.new(@
|
78
|
+
SumAll.new(@object + value)
|
60
79
|
end
|
61
80
|
end
|
62
81
|
|
@@ -72,33 +91,42 @@ module LazyHelpers
|
|
72
91
|
GraphQL::DeprecatedDSL.activate
|
73
92
|
end
|
74
93
|
|
75
|
-
LazyQuery
|
76
|
-
|
77
|
-
|
78
|
-
argument :
|
79
|
-
|
80
|
-
|
94
|
+
class LazyQuery < GraphQL::Schema::Object
|
95
|
+
field :int, Integer, null: false do
|
96
|
+
argument :value, Integer, required: true
|
97
|
+
argument :plus, Integer, required: false, default_value: 0
|
98
|
+
end
|
99
|
+
def int(value:, plus:)
|
100
|
+
Wrapper.new(value + plus)
|
81
101
|
end
|
82
102
|
|
83
|
-
field :
|
84
|
-
argument :value,
|
85
|
-
resolve ->(o, args, c) { SumAll.new(c, args[:value]) }
|
103
|
+
field :nested_sum, LazySum, null: false do
|
104
|
+
argument :value, Integer, required: true
|
86
105
|
end
|
87
106
|
|
88
|
-
|
89
|
-
|
90
|
-
resolve ->(o, args, c) {
|
91
|
-
if args[:value] == 13
|
92
|
-
Wrapper.new { raise GraphQL::ExecutionError.new("13 is unlucky") }
|
93
|
-
else
|
94
|
-
SumAll.new(c, args[:value])
|
95
|
-
end
|
96
|
-
}
|
107
|
+
def nested_sum(value:)
|
108
|
+
SumAll.new(value)
|
97
109
|
end
|
98
110
|
|
99
|
-
field :
|
100
|
-
argument :
|
101
|
-
|
111
|
+
field :nullable_nested_sum, LazySum, null: true do
|
112
|
+
argument :value, Integer, required: true
|
113
|
+
end
|
114
|
+
|
115
|
+
def nullable_nested_sum(value:)
|
116
|
+
if value == MAGIC_NUMBER_THAT_RAISES_ERROR
|
117
|
+
Wrapper.new { raise GraphQL::ExecutionError.new("#{MAGIC_NUMBER_THAT_RAISES_ERROR} is unlucky") }
|
118
|
+
elsif value == MAGIC_NUMBER_THAT_RETURNS_NIL
|
119
|
+
nil
|
120
|
+
else
|
121
|
+
SumAll.new(value)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
field :list_sum, [LazySum, null: true], null: true do
|
126
|
+
argument :values, [Integer], required: true
|
127
|
+
end
|
128
|
+
def list_sum(values:)
|
129
|
+
values.map { |v| v == MAGIC_NUMBER_THAT_RETURNS_NIL ? nil : v }
|
102
130
|
end
|
103
131
|
end
|
104
132
|
|
@@ -142,9 +170,23 @@ module LazyHelpers
|
|
142
170
|
instrument(:query, SumAllInstrumentation.new(counter: nil))
|
143
171
|
instrument(:multiplex, SumAllInstrumentation.new(counter: 1))
|
144
172
|
instrument(:multiplex, SumAllInstrumentation.new(counter: 2))
|
173
|
+
|
174
|
+
if TESTING_INTERPRETER
|
175
|
+
use GraphQL::Execution::Interpreter
|
176
|
+
use GraphQL::Analysis::AST
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.sync_lazy(lazy)
|
180
|
+
if lazy.is_a?(SumAll) && lazy.own_value > 1000
|
181
|
+
lazy.value # clear the previous set
|
182
|
+
lazy.own_value - 900
|
183
|
+
else
|
184
|
+
super
|
185
|
+
end
|
186
|
+
end
|
145
187
|
end
|
146
188
|
|
147
|
-
def run_query(query_str)
|
148
|
-
LazySchema.execute(query_str)
|
189
|
+
def run_query(query_str, **rest)
|
190
|
+
LazySchema.execute(query_str, **rest)
|
149
191
|
end
|
150
192
|
end
|
data/spec/support/new_relic.rb
CHANGED
@@ -6,9 +6,11 @@ end
|
|
6
6
|
|
7
7
|
module NewRelic
|
8
8
|
TRANSACTION_NAMES = []
|
9
|
+
EXECUTION_SCOPES = []
|
9
10
|
# Reset state between tests
|
10
11
|
def self.clear_all
|
11
12
|
TRANSACTION_NAMES.clear
|
13
|
+
EXECUTION_SCOPES.clear
|
12
14
|
end
|
13
15
|
module Agent
|
14
16
|
def self.set_transaction_name(name)
|
@@ -17,6 +19,7 @@ module NewRelic
|
|
17
19
|
|
18
20
|
module MethodTracerHelpers
|
19
21
|
def self.trace_execution_scoped(trace_name)
|
22
|
+
EXECUTION_SCOPES << trace_name
|
20
23
|
yield
|
21
24
|
end
|
22
25
|
end
|
data/spec/support/skylight.rb
CHANGED
@@ -9,9 +9,11 @@ end
|
|
9
9
|
|
10
10
|
module Skylight
|
11
11
|
ENDPOINT_NAMES = []
|
12
|
+
TITLE_NAMES = []
|
12
13
|
# Reset state between tests
|
13
14
|
def self.clear_all
|
14
15
|
ENDPOINT_NAMES.clear
|
16
|
+
TITLE_NAMES.clear
|
15
17
|
end
|
16
18
|
|
17
19
|
def self.instrumenter
|
@@ -19,6 +21,7 @@ module Skylight
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def self.instrument(category:, title:)
|
24
|
+
TITLE_NAMES << title
|
22
25
|
yield
|
23
26
|
end
|
24
27
|
|