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
@@ -17,8 +17,8 @@ module GraphQL
|
|
17
17
|
# @param set_endpoint_name [Boolean] If true, the GraphQL operation name will be used as the endpoint name.
|
18
18
|
# This is not advised if you run more than one query per HTTP request, for example, with `graphql-client` or multiplexing.
|
19
19
|
# It can also be specified per-query with `context[:set_skylight_endpoint_name]`.
|
20
|
-
def initialize(
|
21
|
-
@set_endpoint_name = set_endpoint_name
|
20
|
+
def initialize(options = {})
|
21
|
+
@set_endpoint_name = options.fetch(:set_endpoint_name, false)
|
22
22
|
super
|
23
23
|
end
|
24
24
|
|
@@ -54,7 +54,7 @@ module GraphQL
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def platform_field_key(type, field)
|
57
|
-
"graphql.#{type.
|
57
|
+
"graphql.#{type.graphql_name}.#{field.graphql_name}"
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
data/lib/graphql/tracing.rb
CHANGED
@@ -15,11 +15,6 @@ end
|
|
15
15
|
module GraphQL
|
16
16
|
# Library entry point for performance metric reporting.
|
17
17
|
#
|
18
|
-
# {ActiveSupportNotificationsTracing} is imported by default
|
19
|
-
# when `ActiveSupport::Notifications` is found.
|
20
|
-
#
|
21
|
-
# You can remove it with `GraphQL::Tracing.uninstall(GraphQL::Tracing::ActiveSupportNotificationsTracing)`.
|
22
|
-
#
|
23
18
|
# __Warning:__ Installing/uninstalling tracers is not thread-safe. Do it during application boot only.
|
24
19
|
#
|
25
20
|
# @example Sending custom events
|
@@ -32,7 +27,7 @@ module GraphQL
|
|
32
27
|
# tracer MyTracer # <= responds to .trace(key, data, &block)
|
33
28
|
# end
|
34
29
|
#
|
35
|
-
# @example Adding a tracer to a query
|
30
|
+
# @example Adding a tracer to a single query
|
36
31
|
# MySchema.execute(query_str, context: { backtrace: true })
|
37
32
|
#
|
38
33
|
# Events:
|
@@ -47,8 +42,13 @@ module GraphQL
|
|
47
42
|
# execute_multiplex | `{ multiplex: GraphQL::Execution::Multiplex }`
|
48
43
|
# execute_query | `{ query: GraphQL::Query }`
|
49
44
|
# execute_query_lazy | `{ query: GraphQL::Query?, multiplex: GraphQL::Execution::Multiplex? }`
|
50
|
-
# execute_field | `{ context: GraphQL::Query::Context::FieldResolutionContext }`
|
51
|
-
# execute_field_lazy | `{ context: GraphQL::Query::Context::FieldResolutionContext }`
|
45
|
+
# execute_field | `{ context: GraphQL::Query::Context::FieldResolutionContext?, field: GraphQL::Schema::Field?, path: Array<String, Integer>?}`
|
46
|
+
# execute_field_lazy | `{ context: GraphQL::Query::Context::FieldResolutionContext?, field: GraphQL::Schema::Field?, path: Array<String, Integer>?}`
|
47
|
+
#
|
48
|
+
# Note that `execute_field` and `execute_field_lazy` receive different data in different settings:
|
49
|
+
#
|
50
|
+
# - When using {GraphQL::Execution::Interpreter}, they receive `{field:, path:}`
|
51
|
+
# - Otherwise, they receive `{context: ...}`
|
52
52
|
#
|
53
53
|
module Tracing
|
54
54
|
# Objects may include traceable to gain a `.trace(...)` method.
|
data/lib/graphql/types/float.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module GraphQL
|
4
4
|
module Types
|
5
5
|
class Float < GraphQL::Schema::Scalar
|
6
|
-
description "Represents signed double-precision fractional values as specified by [IEEE 754](
|
6
|
+
description "Represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point)."
|
7
7
|
|
8
8
|
def self.coerce_input(value, _ctx)
|
9
9
|
value.is_a?(Numeric) ? value.to_f : nil
|
data/lib/graphql/types/int.rb
CHANGED
@@ -5,12 +5,21 @@ module GraphQL
|
|
5
5
|
class Int < GraphQL::Schema::Scalar
|
6
6
|
description "Represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1."
|
7
7
|
|
8
|
+
MIN = -(2**31)
|
9
|
+
MAX = (2**31) - 1
|
10
|
+
|
8
11
|
def self.coerce_input(value, _ctx)
|
9
12
|
value.is_a?(Numeric) ? value.to_i : nil
|
10
13
|
end
|
11
14
|
|
12
|
-
def self.coerce_result(value,
|
13
|
-
value.to_i
|
15
|
+
def self.coerce_result(value, ctx)
|
16
|
+
value = value.to_i
|
17
|
+
if value >= MIN && value <= MAX
|
18
|
+
value
|
19
|
+
else
|
20
|
+
err = GraphQL::IntegerEncodingError.new(value)
|
21
|
+
ctx.schema.type_error(err, ctx)
|
22
|
+
end
|
14
23
|
end
|
15
24
|
|
16
25
|
default_scalar true
|
@@ -15,10 +15,24 @@ module GraphQL
|
|
15
15
|
class ISO8601DateTime < GraphQL::Schema::Scalar
|
16
16
|
description "An ISO 8601-encoded datetime"
|
17
17
|
|
18
|
+
# It's not compatible with Rails' default,
|
19
|
+
# i.e. ActiveSupport::JSON::Encoder.time_precision (3 by default)
|
20
|
+
DEFAULT_TIME_PRECISION = 0
|
21
|
+
|
22
|
+
# @return [Integer]
|
23
|
+
def self.time_precision
|
24
|
+
@time_precision || DEFAULT_TIME_PRECISION
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param [Integer] value
|
28
|
+
def self.time_precision=(value)
|
29
|
+
@time_precision = value
|
30
|
+
end
|
31
|
+
|
18
32
|
# @param value [DateTime]
|
19
33
|
# @return [String]
|
20
34
|
def self.coerce_result(value, _ctx)
|
21
|
-
value.iso8601
|
35
|
+
value.iso8601(time_precision)
|
22
36
|
end
|
23
37
|
|
24
38
|
# @param str_value [String]
|
@@ -35,6 +35,9 @@ module GraphQL
|
|
35
35
|
# @return [Class]
|
36
36
|
attr_reader :node_type
|
37
37
|
|
38
|
+
# @return [Class]
|
39
|
+
attr_reader :edge_class
|
40
|
+
|
38
41
|
# Configure this connection to return `edges` and `nodes` based on `edge_type_class`.
|
39
42
|
#
|
40
43
|
# This method will use the inputs to create:
|
@@ -51,11 +54,11 @@ module GraphQL
|
|
51
54
|
|
52
55
|
@node_type = node_type
|
53
56
|
@edge_type = edge_type_class
|
57
|
+
@edge_class = edge_class
|
54
58
|
|
55
59
|
field :edges, [edge_type_class, null: true],
|
56
60
|
null: true,
|
57
61
|
description: "A list of edges.",
|
58
|
-
method: :edge_nodes,
|
59
62
|
edge_class: edge_class
|
60
63
|
|
61
64
|
define_nodes_field if nodes_field
|
@@ -101,6 +104,17 @@ module GraphQL
|
|
101
104
|
def nodes
|
102
105
|
@object.edge_nodes
|
103
106
|
end
|
107
|
+
|
108
|
+
def edges
|
109
|
+
if context.interpreter?
|
110
|
+
context.schema.after_lazy(object.edge_nodes) do |nodes|
|
111
|
+
nodes.map { |n| self.class.edge_class.new(n, object) }
|
112
|
+
end
|
113
|
+
else
|
114
|
+
# This is done by edges_instrumentation
|
115
|
+
@object.edge_nodes
|
116
|
+
end
|
117
|
+
end
|
104
118
|
end
|
105
119
|
end
|
106
120
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
module Types
|
4
|
+
module Relay
|
5
|
+
# This can be used for implementing `Query.node(id: ...)`,
|
6
|
+
# or use it for inspiration for your own field definition.
|
7
|
+
#
|
8
|
+
# @example Adding this field directly
|
9
|
+
# add_field(GraphQL::Types::Relay::NodeField)
|
10
|
+
#
|
11
|
+
# @example Implementing a similar field in your own Query root
|
12
|
+
#
|
13
|
+
# field :node, GraphQL::Types::Relay::Node, null: true,
|
14
|
+
# description: "Fetches an object given its ID" do
|
15
|
+
# argument :id, ID, required: true
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# def node(id:)
|
19
|
+
# context.schema.object_from_id(context, id)
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
NodeField = GraphQL::Schema::Field.new(
|
23
|
+
name: "node",
|
24
|
+
owner: nil,
|
25
|
+
type: GraphQL::Types::Relay::Node,
|
26
|
+
null: true,
|
27
|
+
description: "Fetches an object given its ID.",
|
28
|
+
relay_node_field: true,
|
29
|
+
) do
|
30
|
+
argument :id, "ID!", required: true,
|
31
|
+
description: "ID of the object."
|
32
|
+
|
33
|
+
def resolve(obj, args, ctx)
|
34
|
+
ctx.schema.object_from_id(args[:id], ctx)
|
35
|
+
end
|
36
|
+
|
37
|
+
def resolve_field(obj, args, ctx)
|
38
|
+
resolve(obj, args, ctx)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
module Types
|
4
|
+
module Relay
|
5
|
+
# This can be used for implementing `Query.nodes(ids: ...)`,
|
6
|
+
# or use it for inspiration for your own field definition.
|
7
|
+
#
|
8
|
+
# @example Adding this field directly
|
9
|
+
# add_field(GraphQL::Types::Relay::NodesField)
|
10
|
+
#
|
11
|
+
# @example Implementing a similar field in your own Query root
|
12
|
+
#
|
13
|
+
# field :nodes, [GraphQL::Types::Relay::Node, null: true], null: false,
|
14
|
+
# description: Fetches a list of objects given a list of IDs." do
|
15
|
+
# argument :ids, [ID], required: true
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# def nodes(ids:)
|
19
|
+
# ids.map do |id|
|
20
|
+
# context.schema.object_from_id(context, id)
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
NodesField = GraphQL::Schema::Field.new(
|
25
|
+
name: "nodes",
|
26
|
+
owner: nil,
|
27
|
+
type: [GraphQL::Types::Relay::Node, null: true],
|
28
|
+
null: false,
|
29
|
+
description: "Fetches a list of objects given a list of IDs.",
|
30
|
+
relay_nodes_field: true,
|
31
|
+
) do
|
32
|
+
argument :ids, "[ID!]!", required: true,
|
33
|
+
description: "IDs of the objects."
|
34
|
+
|
35
|
+
def resolve(obj, args, ctx)
|
36
|
+
args[:ids].map { |id| ctx.schema.object_from_id(id, ctx) }
|
37
|
+
end
|
38
|
+
|
39
|
+
def resolve_field(obj, args, ctx)
|
40
|
+
resolve(obj, args, ctx)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/graphql/types/relay.rb
CHANGED
@@ -6,6 +6,8 @@ require "graphql/types/relay/page_info"
|
|
6
6
|
require "graphql/types/relay/base_connection"
|
7
7
|
require "graphql/types/relay/base_edge"
|
8
8
|
require "graphql/types/relay/node"
|
9
|
+
require "graphql/types/relay/node_field"
|
10
|
+
require "graphql/types/relay/nodes_field"
|
9
11
|
|
10
12
|
module GraphQL
|
11
13
|
module Types
|
@@ -1,5 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module GraphQL
|
3
|
+
# When an `authorized?` hook returns false, this error is used to communicate the failure.
|
4
|
+
# It's passed to {Schema.unauthorized_object}.
|
5
|
+
#
|
6
|
+
# Alternatively, custom code in `authorized?` may raise this error. It will be routed the same way.
|
3
7
|
class UnauthorizedError < GraphQL::Error
|
4
8
|
# @return [Object] the application object that failed the authorization check
|
5
9
|
attr_reader :object
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
class UnauthorizedFieldError < GraphQL::UnauthorizedError
|
4
|
+
# @return [Field] the field that failed the authorization check
|
5
|
+
attr_reader :field
|
6
|
+
|
7
|
+
def initialize(message = nil, object: nil, type: nil, context: nil, field: nil)
|
8
|
+
if message.nil? && [field, type].any?(&:nil?)
|
9
|
+
raise ArgumentError, "#{self.class.name} requires either a message or keywords"
|
10
|
+
end
|
11
|
+
|
12
|
+
@field = field
|
13
|
+
message ||= begin
|
14
|
+
if object
|
15
|
+
"An instance of #{object.class} failed #{type.name}'s authorization check on field #{field.name}"
|
16
|
+
else
|
17
|
+
"Failed #{type.name}'s authorization check on field #{field.name}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
super(message, object: object, type: type, context: context)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -19,6 +19,7 @@ module GraphQL
|
|
19
19
|
# Recursively transform a `.define`-DSL-based type expression into a class-ready expression, for example:
|
20
20
|
#
|
21
21
|
# - `types[X]` -> `[X, null: true]`
|
22
|
+
# - `types[X.to_non_null_type]` -> `[X]`
|
22
23
|
# - `Int` -> `Integer`
|
23
24
|
# - `X!` -> `X`
|
24
25
|
#
|
@@ -37,6 +38,9 @@ module GraphQL
|
|
37
38
|
if inner_type.start_with?("!")
|
38
39
|
nullable = false
|
39
40
|
inner_type = inner_type[1..-1]
|
41
|
+
elsif inner_type.end_with?(".to_non_null_type")
|
42
|
+
nullable = false
|
43
|
+
inner_type = inner_type[0...-17]
|
40
44
|
else
|
41
45
|
nullable = true
|
42
46
|
end
|
@@ -647,6 +651,7 @@ module GraphQL
|
|
647
651
|
|
648
652
|
if return_type
|
649
653
|
non_nullable = return_type.sub! /(^|[^\[])!/, '\1'
|
654
|
+
non_nullable ||= return_type.sub! /([^\[])\.to_non_null_type([^\]]|$)/, '\1'
|
650
655
|
nullable = !non_nullable
|
651
656
|
return_type = normalize_type_expression(return_type)
|
652
657
|
else
|
data/lib/graphql/version.rb
CHANGED
data/lib/graphql.rb
CHANGED
@@ -60,14 +60,16 @@ require "graphql/type_kinds"
|
|
60
60
|
require "graphql/backwards_compatibility"
|
61
61
|
require "graphql/scalar_type"
|
62
62
|
|
63
|
-
require "graphql/directive"
|
64
63
|
require "graphql/name_validator"
|
65
64
|
|
66
65
|
require "graphql/language"
|
67
66
|
require "graphql/analysis"
|
68
67
|
require "graphql/tracing"
|
69
68
|
require "graphql/execution"
|
69
|
+
require "graphql/dig"
|
70
70
|
require "graphql/schema"
|
71
|
+
require "graphql/directive"
|
72
|
+
require "graphql/execution"
|
71
73
|
require "graphql/types"
|
72
74
|
require "graphql/relay"
|
73
75
|
require "graphql/boolean_type"
|
@@ -82,10 +84,12 @@ require "graphql/introspection"
|
|
82
84
|
|
83
85
|
require "graphql/analysis_error"
|
84
86
|
require "graphql/coercion_error"
|
87
|
+
require "graphql/literal_validation_error"
|
85
88
|
require "graphql/runtime_type_error"
|
86
89
|
require "graphql/invalid_null_error"
|
87
90
|
require "graphql/invalid_name_error"
|
88
91
|
require "graphql/unresolved_type_error"
|
92
|
+
require "graphql/integer_encoding_error"
|
89
93
|
require "graphql/string_encoding_error"
|
90
94
|
require "graphql/query"
|
91
95
|
require "graphql/internal_representation"
|
@@ -101,3 +105,4 @@ require "graphql/backtrace"
|
|
101
105
|
require "graphql/deprecated_dsl"
|
102
106
|
require "graphql/authorization"
|
103
107
|
require "graphql/unauthorized_error"
|
108
|
+
require "graphql/unauthorized_field_error"
|
data/readme.md
CHANGED
@@ -4,12 +4,12 @@
|
|
4
4
|
[](https://rubygems.org/gems/graphql)
|
5
5
|
[](https://codeclimate.com/github/rmosolgo/graphql-ruby)
|
6
6
|
[](https://codeclimate.com/github/rmosolgo/graphql-ruby)
|
7
|
-
[](
|
7
|
+
[](https://rmosolgo.github.io/react-badges/)
|
8
8
|
|
9
|
-
A Ruby implementation of [GraphQL](
|
9
|
+
A Ruby implementation of [GraphQL](https://graphql.org/).
|
10
10
|
|
11
|
-
- [Website](https://
|
12
|
-
- [API Documentation](
|
11
|
+
- [Website](https://graphql-ruby.org/)
|
12
|
+
- [API Documentation](https://www.rubydoc.info/gems/graphql)
|
13
13
|
- [Newsletter](https://tinyletter.com/graphql-ruby)
|
14
14
|
|
15
15
|
## Installation
|
@@ -33,11 +33,11 @@ $ rails generate graphql:install
|
|
33
33
|
|
34
34
|
After this, you may need to run `bundle install` again, as by default graphiql-rails is added on installation.
|
35
35
|
|
36
|
-
Or, see ["Getting Started"](https://
|
36
|
+
Or, see ["Getting Started"](https://graphql-ruby.org/).
|
37
37
|
|
38
38
|
## Upgrade
|
39
39
|
|
40
|
-
I also sell [GraphQL::Pro](
|
40
|
+
I also sell [GraphQL::Pro](https://graphql.pro) which provides several features on top of the GraphQL runtime, including [Pundit authorization](https://graphql-ruby.org/authorization/pundit_integration), [CanCan authorization](https://graphql-ruby.org/authorization/can_can_integration), [Pusher-based subscriptions](https://graphql-ruby.org/subscriptions/pusher_implementation) and [persisted queries](https://graphql-ruby.org/operation_store/overview). Besides that, Pro customers get email support and an opportunity to support graphql-ruby's development!
|
41
41
|
|
42
42
|
## Goals
|
43
43
|
|
@@ -49,4 +49,4 @@ I also sell [GraphQL::Pro](http://graphql.pro) which provides several features o
|
|
49
49
|
|
50
50
|
- __Say hi & ask questions__ in the [#ruby channel on Slack](https://graphql-slack.herokuapp.com/) or [on Twitter](https://twitter.com/rmosolgo)!
|
51
51
|
- __Report bugs__ by posting a description, full stack trace, and all relevant code in a [GitHub issue](https://github.com/rmosolgo/graphql-ruby/issues).
|
52
|
-
- __Start hacking__ with the [Development guide](
|
52
|
+
- __Start hacking__ with the [Development guide](https://graphql-ruby.org/development).
|
data/spec/dummy/Gemfile
CHANGED
@@ -0,0 +1,157 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/rmosolgo/code/graphql-ruby
|
3
|
+
specs:
|
4
|
+
graphql (1.9.0.pre2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actioncable (5.2.1)
|
10
|
+
actionpack (= 5.2.1)
|
11
|
+
nio4r (~> 2.0)
|
12
|
+
websocket-driver (>= 0.6.1)
|
13
|
+
actionmailer (5.2.1)
|
14
|
+
actionpack (= 5.2.1)
|
15
|
+
actionview (= 5.2.1)
|
16
|
+
activejob (= 5.2.1)
|
17
|
+
mail (~> 2.5, >= 2.5.4)
|
18
|
+
rails-dom-testing (~> 2.0)
|
19
|
+
actionpack (5.2.1)
|
20
|
+
actionview (= 5.2.1)
|
21
|
+
activesupport (= 5.2.1)
|
22
|
+
rack (~> 2.0)
|
23
|
+
rack-test (>= 0.6.3)
|
24
|
+
rails-dom-testing (~> 2.0)
|
25
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
26
|
+
actionview (5.2.1)
|
27
|
+
activesupport (= 5.2.1)
|
28
|
+
builder (~> 3.1)
|
29
|
+
erubi (~> 1.4)
|
30
|
+
rails-dom-testing (~> 2.0)
|
31
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
32
|
+
activejob (5.2.1)
|
33
|
+
activesupport (= 5.2.1)
|
34
|
+
globalid (>= 0.3.6)
|
35
|
+
activemodel (5.2.1)
|
36
|
+
activesupport (= 5.2.1)
|
37
|
+
activerecord (5.2.1)
|
38
|
+
activemodel (= 5.2.1)
|
39
|
+
activesupport (= 5.2.1)
|
40
|
+
arel (>= 9.0)
|
41
|
+
activestorage (5.2.1)
|
42
|
+
actionpack (= 5.2.1)
|
43
|
+
activerecord (= 5.2.1)
|
44
|
+
marcel (~> 0.3.1)
|
45
|
+
activesupport (5.2.1)
|
46
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
47
|
+
i18n (>= 0.7, < 2)
|
48
|
+
minitest (~> 5.1)
|
49
|
+
tzinfo (~> 1.1)
|
50
|
+
addressable (2.5.2)
|
51
|
+
public_suffix (>= 2.0.2, < 4.0)
|
52
|
+
arel (9.0.0)
|
53
|
+
builder (3.2.3)
|
54
|
+
capybara (3.7.2)
|
55
|
+
addressable
|
56
|
+
mini_mime (>= 0.1.3)
|
57
|
+
nokogiri (~> 1.8)
|
58
|
+
rack (>= 1.6.0)
|
59
|
+
rack-test (>= 0.6.3)
|
60
|
+
xpath (~> 3.1)
|
61
|
+
childprocess (0.9.0)
|
62
|
+
ffi (~> 1.0, >= 1.0.11)
|
63
|
+
concurrent-ruby (1.0.5)
|
64
|
+
crass (1.0.4)
|
65
|
+
erubi (1.7.1)
|
66
|
+
ffi (1.9.25)
|
67
|
+
globalid (0.4.1)
|
68
|
+
activesupport (>= 4.2.0)
|
69
|
+
i18n (1.1.0)
|
70
|
+
concurrent-ruby (~> 1.0)
|
71
|
+
listen (3.1.5)
|
72
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
73
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
74
|
+
ruby_dep (~> 1.2)
|
75
|
+
loofah (2.2.2)
|
76
|
+
crass (~> 1.0.2)
|
77
|
+
nokogiri (>= 1.5.9)
|
78
|
+
mail (2.7.0)
|
79
|
+
mini_mime (>= 0.1.1)
|
80
|
+
marcel (0.3.3)
|
81
|
+
mimemagic (~> 0.3.2)
|
82
|
+
method_source (0.9.0)
|
83
|
+
mimemagic (0.3.2)
|
84
|
+
mini_mime (1.0.1)
|
85
|
+
mini_portile2 (2.3.0)
|
86
|
+
minitest (5.11.3)
|
87
|
+
nio4r (2.3.1)
|
88
|
+
nokogiri (1.8.4)
|
89
|
+
mini_portile2 (~> 2.3.0)
|
90
|
+
public_suffix (3.0.3)
|
91
|
+
puma (3.12.0)
|
92
|
+
rack (2.0.5)
|
93
|
+
rack-test (1.1.0)
|
94
|
+
rack (>= 1.0, < 3)
|
95
|
+
rails (5.2.1)
|
96
|
+
actioncable (= 5.2.1)
|
97
|
+
actionmailer (= 5.2.1)
|
98
|
+
actionpack (= 5.2.1)
|
99
|
+
actionview (= 5.2.1)
|
100
|
+
activejob (= 5.2.1)
|
101
|
+
activemodel (= 5.2.1)
|
102
|
+
activerecord (= 5.2.1)
|
103
|
+
activestorage (= 5.2.1)
|
104
|
+
activesupport (= 5.2.1)
|
105
|
+
bundler (>= 1.3.0)
|
106
|
+
railties (= 5.2.1)
|
107
|
+
sprockets-rails (>= 2.0.0)
|
108
|
+
rails-dom-testing (2.0.3)
|
109
|
+
activesupport (>= 4.2.0)
|
110
|
+
nokogiri (>= 1.6)
|
111
|
+
rails-html-sanitizer (1.0.4)
|
112
|
+
loofah (~> 2.2, >= 2.2.2)
|
113
|
+
railties (5.2.1)
|
114
|
+
actionpack (= 5.2.1)
|
115
|
+
activesupport (= 5.2.1)
|
116
|
+
method_source
|
117
|
+
rake (>= 0.8.7)
|
118
|
+
thor (>= 0.19.0, < 2.0)
|
119
|
+
rake (12.3.1)
|
120
|
+
rb-fsevent (0.10.3)
|
121
|
+
rb-inotify (0.9.10)
|
122
|
+
ffi (>= 0.5.0, < 2)
|
123
|
+
ruby_dep (1.5.0)
|
124
|
+
rubyzip (1.2.2)
|
125
|
+
selenium-webdriver (3.14.0)
|
126
|
+
childprocess (~> 0.5)
|
127
|
+
rubyzip (~> 1.2)
|
128
|
+
sprockets (3.7.2)
|
129
|
+
concurrent-ruby (~> 1.0)
|
130
|
+
rack (> 1, < 3)
|
131
|
+
sprockets-rails (3.2.1)
|
132
|
+
actionpack (>= 4.0)
|
133
|
+
activesupport (>= 4.0)
|
134
|
+
sprockets (>= 3.0.0)
|
135
|
+
thor (0.20.0)
|
136
|
+
thread_safe (0.3.6)
|
137
|
+
tzinfo (1.2.5)
|
138
|
+
thread_safe (~> 0.1)
|
139
|
+
websocket-driver (0.7.0)
|
140
|
+
websocket-extensions (>= 0.1.0)
|
141
|
+
websocket-extensions (0.1.3)
|
142
|
+
xpath (3.1.0)
|
143
|
+
nokogiri (~> 1.8)
|
144
|
+
|
145
|
+
PLATFORMS
|
146
|
+
ruby
|
147
|
+
|
148
|
+
DEPENDENCIES
|
149
|
+
capybara
|
150
|
+
graphql!
|
151
|
+
listen
|
152
|
+
puma
|
153
|
+
rails (~> 5.2.1)
|
154
|
+
selenium-webdriver
|
155
|
+
|
156
|
+
BUNDLED WITH
|
157
|
+
2.0.1
|
@@ -1,20 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
class GraphqlChannel < ActionCable::Channel::Base
|
3
|
-
QueryType
|
4
|
-
|
5
|
-
|
3
|
+
class QueryType < GraphQL::Schema::Object
|
4
|
+
field :value, Integer, null: false
|
5
|
+
def value
|
6
|
+
3
|
7
|
+
end
|
6
8
|
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
field :payload, PayloadType do
|
11
|
-
argument :id, !types.ID
|
12
|
-
end
|
10
|
+
class PayloadType < GraphQL::Schema::Object
|
11
|
+
field :value, Integer, null: false
|
13
12
|
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
class SubscriptionType < GraphQL::Schema::Object
|
15
|
+
if TESTING_INTERPRETER
|
16
|
+
extend GraphQL::Subscriptions::SubscriptionRoot
|
17
|
+
else
|
18
|
+
def payload(id:)
|
19
|
+
id
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
field :payload, PayloadType, null: false do
|
24
|
+
argument :id, ID, required: true
|
25
|
+
end
|
18
26
|
end
|
19
27
|
|
20
28
|
# Wacky behavior around the number 4
|
@@ -42,6 +50,9 @@ class GraphqlChannel < ActionCable::Channel::Base
|
|
42
50
|
subscription(SubscriptionType)
|
43
51
|
use GraphQL::Subscriptions::ActionCableSubscriptions,
|
44
52
|
serializer: CustomSerializer
|
53
|
+
if TESTING_INTERPRETER
|
54
|
+
use GraphQL::Execution::Interpreter
|
55
|
+
end
|
45
56
|
end
|
46
57
|
|
47
58
|
def subscribed
|