graphql 2.6.12 → 2.6.13
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/.rdoc_options +4 -0
- data/lib/generators/graphql/core.rb +1 -0
- data/lib/generators/graphql/detailed_trace_generator.rb +1 -0
- data/lib/generators/graphql/enum_generator.rb +1 -0
- data/lib/generators/graphql/field_extractor.rb +1 -0
- data/lib/generators/graphql/input_generator.rb +1 -0
- data/lib/generators/graphql/install/mutation_root_generator.rb +1 -0
- data/lib/generators/graphql/install_generator.rb +1 -0
- data/lib/generators/graphql/interface_generator.rb +1 -0
- data/lib/generators/graphql/loader_generator.rb +8 -2
- data/lib/generators/graphql/mutation_create_generator.rb +8 -2
- data/lib/generators/graphql/mutation_delete_generator.rb +8 -2
- data/lib/generators/graphql/mutation_generator.rb +8 -2
- data/lib/generators/graphql/mutation_update_generator.rb +8 -2
- data/lib/generators/graphql/object_generator.rb +1 -0
- data/lib/generators/graphql/orm_mutations_base.rb +8 -2
- data/lib/generators/graphql/relay.rb +1 -0
- data/lib/generators/graphql/relay_generator.rb +1 -0
- data/lib/generators/graphql/scalar_generator.rb +1 -0
- data/lib/generators/graphql/type_generator.rb +38 -8
- data/lib/generators/graphql/union_generator.rb +1 -0
- data/lib/graphql/analysis/analyzer.rb +35 -9
- data/lib/graphql/analysis/field_usage.rb +1 -0
- data/lib/graphql/analysis/max_query_complexity.rb +2 -1
- data/lib/graphql/analysis/max_query_depth.rb +1 -0
- data/lib/graphql/analysis/query_complexity.rb +57 -20
- data/lib/graphql/analysis/query_depth.rb +17 -12
- data/lib/graphql/analysis/visitor.rb +79 -16
- data/lib/graphql/analysis.rb +23 -6
- data/lib/graphql/analysis_error.rb +1 -0
- data/lib/graphql/autoload.rb +30 -7
- data/lib/graphql/backtrace/table.rb +21 -5
- data/lib/graphql/backtrace/traced_error.rb +8 -3
- data/lib/graphql/backtrace.rb +14 -9
- data/lib/graphql/coercion_error.rb +1 -0
- data/lib/graphql/current.rb +44 -19
- data/lib/graphql/dashboard/application_controller.rb +1 -0
- data/lib/graphql/dashboard/detailed_traces.rb +1 -0
- data/lib/graphql/dashboard/installable.rb +1 -0
- data/lib/graphql/dashboard/landings_controller.rb +1 -0
- data/lib/graphql/dashboard/limiters.rb +1 -0
- data/lib/graphql/dashboard/operation_store.rb +1 -0
- data/lib/graphql/dashboard/statics_controller.rb +1 -0
- data/lib/graphql/dashboard/subscriptions.rb +1 -0
- data/lib/graphql/dashboard.rb +36 -22
- data/lib/graphql/dataloader/active_record_association_source.rb +1 -0
- data/lib/graphql/dataloader/active_record_source.rb +1 -0
- data/lib/graphql/dataloader/async_dataloader.rb +8 -7
- data/lib/graphql/dataloader/null_dataloader.rb +4 -3
- data/lib/graphql/dataloader/request.rb +8 -2
- data/lib/graphql/dataloader/request_all.rb +8 -2
- data/lib/graphql/dataloader/source.rb +127 -35
- data/lib/graphql/dataloader.rb +91 -42
- data/lib/graphql/date_encoding_error.rb +2 -1
- data/lib/graphql/dig.rb +12 -3
- data/lib/graphql/duration_encoding_error.rb +2 -1
- data/lib/graphql/execution/directive_checks.rb +8 -3
- data/lib/graphql/execution/errors.rb +20 -6
- data/lib/graphql/execution/field_resolve_step.rb +22 -6
- data/lib/graphql/execution/finalize.rb +12 -6
- data/lib/graphql/execution/input_values.rb +2 -1
- data/lib/graphql/execution/interpreter/argument_value.rb +17 -5
- data/lib/graphql/execution/interpreter/arguments.rb +24 -9
- data/lib/graphql/execution/interpreter/arguments_cache.rb +2 -1
- data/lib/graphql/execution/interpreter/execution_errors.rb +1 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +1 -0
- data/lib/graphql/execution/interpreter/resolve.rb +18 -8
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +4 -1
- data/lib/graphql/execution/interpreter/runtime.rb +66 -23
- data/lib/graphql/execution/interpreter.rb +15 -6
- data/lib/graphql/execution/lazy/lazy_method_map.rb +21 -8
- data/lib/graphql/execution/lazy.rb +34 -10
- data/lib/graphql/execution/load_argument_step.rb +1 -0
- data/lib/graphql/execution/lookahead.rb +137 -54
- data/lib/graphql/execution/multiplex.rb +4 -4
- data/lib/graphql/execution/next.rb +7 -0
- data/lib/graphql/execution/prepare_object_step.rb +1 -0
- data/lib/graphql/execution/resolve_type_step.rb +2 -1
- data/lib/graphql/execution/runner.rb +9 -3
- data/lib/graphql/execution/selections_step.rb +3 -2
- data/lib/graphql/execution.rb +2 -2
- data/lib/graphql/execution_error.rb +19 -10
- data/lib/graphql/float_decoding_error.rb +1 -0
- data/lib/graphql/float_encoding_error.rb +7 -2
- data/lib/graphql/integer_decoding_error.rb +2 -1
- data/lib/graphql/integer_encoding_error.rb +8 -3
- data/lib/graphql/introspection/base_object.rb +3 -1
- data/lib/graphql/introspection/directive_location_enum.rb +1 -0
- data/lib/graphql/introspection/directive_type.rb +1 -0
- data/lib/graphql/introspection/dynamic_fields.rb +1 -0
- data/lib/graphql/introspection/entry_points.rb +1 -0
- data/lib/graphql/introspection/enum_value_type.rb +1 -0
- data/lib/graphql/introspection/field_type.rb +1 -0
- data/lib/graphql/introspection/input_value_type.rb +1 -0
- data/lib/graphql/introspection/introspection_query.rb +1 -0
- data/lib/graphql/introspection/schema_type.rb +1 -0
- data/lib/graphql/introspection/type_kind_enum.rb +1 -0
- data/lib/graphql/introspection/type_type.rb +1 -0
- data/lib/graphql/introspection.rb +1 -0
- data/lib/graphql/invalid_name_error.rb +1 -0
- data/lib/graphql/invalid_null_error.rb +19 -6
- data/lib/graphql/language/block_string.rb +2 -1
- data/lib/graphql/language/cache.rb +10 -4
- data/lib/graphql/language/comment.rb +1 -0
- data/lib/graphql/language/definition_slice.rb +1 -0
- data/lib/graphql/language/document_from_schema_definition.rb +9 -10
- data/lib/graphql/language/generation.rb +23 -9
- data/lib/graphql/language/lexer.rb +5 -0
- data/lib/graphql/language/nodes.rb +2094 -419
- data/lib/graphql/language/parser.rb +17 -11
- data/lib/graphql/language/printer.rb +31 -16
- data/lib/graphql/language/sanitized_printer.rb +16 -5
- data/lib/graphql/language/static_visitor.rb +19 -4
- data/lib/graphql/language/visitor.rb +51 -29
- data/lib/graphql/language.rb +13 -7
- data/lib/graphql/load_application_object_failed_error.rb +14 -5
- data/lib/graphql/name_validator.rb +1 -0
- data/lib/graphql/pagination/active_record_relation_connection.rb +1 -0
- data/lib/graphql/pagination/array_connection.rb +20 -6
- data/lib/graphql/pagination/connection.rb +178 -48
- data/lib/graphql/pagination/connections.rb +21 -14
- data/lib/graphql/pagination/mongoid_relation_connection.rb +1 -0
- data/lib/graphql/pagination/relation_connection.rb +118 -21
- data/lib/graphql/pagination/sequel_dataset_connection.rb +1 -0
- data/lib/graphql/pagination.rb +1 -0
- data/lib/graphql/parse_error.rb +1 -0
- data/lib/graphql/query/context/scoped_context.rb +2 -1
- data/lib/graphql/query/context.rb +106 -35
- data/lib/graphql/query/fingerprint.rb +15 -7
- data/lib/graphql/query/input_validation_result.rb +1 -0
- data/lib/graphql/query/null_context.rb +1 -0
- data/lib/graphql/query/partial.rb +28 -15
- data/lib/graphql/query/result.rb +15 -5
- data/lib/graphql/query/validation_pipeline.rb +16 -6
- data/lib/graphql/query/variable_validation_error.rb +1 -0
- data/lib/graphql/query/variables.rb +4 -1
- data/lib/graphql/query.rb +193 -49
- data/lib/graphql/railtie.rb +7 -3
- data/lib/graphql/rake_task/validate.rb +72 -17
- data/lib/graphql/rake_task.rb +55 -23
- data/lib/graphql/relay/range_add.rb +32 -21
- data/lib/graphql/relay.rb +1 -0
- data/lib/graphql/rubocop/graphql/base_cop.rb +1 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +9 -6
- data/lib/graphql/rubocop/graphql/default_required_true.rb +9 -6
- data/lib/graphql/rubocop/graphql/field_type_in_block.rb +12 -8
- data/lib/graphql/rubocop/graphql/root_types_in_block.rb +9 -5
- data/lib/graphql/rubocop.rb +1 -0
- data/lib/graphql/runtime_error.rb +1 -0
- data/lib/graphql/runtime_type_error.rb +1 -0
- data/lib/graphql/schema/addition.rb +18 -6
- data/lib/graphql/schema/always_visible.rb +1 -0
- data/lib/graphql/schema/argument.rb +265 -42
- data/lib/graphql/schema/base_64_encoder.rb +2 -2
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -0
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +2 -2
- data/lib/graphql/schema/build_from_definition.rb +94 -27
- data/lib/graphql/schema/built_in_types.rb +1 -0
- data/lib/graphql/schema/directive/deprecated.rb +1 -0
- data/lib/graphql/schema/directive/feature.rb +39 -22
- data/lib/graphql/schema/directive/flagged.rb +6 -1
- data/lib/graphql/schema/directive/include.rb +1 -0
- data/lib/graphql/schema/directive/one_of.rb +1 -0
- data/lib/graphql/schema/directive/skip.rb +1 -0
- data/lib/graphql/schema/directive/specified_by.rb +1 -0
- data/lib/graphql/schema/directive/transform.rb +17 -8
- data/lib/graphql/schema/directive.rb +12 -7
- data/lib/graphql/schema/enum.rb +99 -38
- data/lib/graphql/schema/enum_value.rb +21 -13
- data/lib/graphql/schema/field/connection_extension.rb +10 -2
- data/lib/graphql/schema/field/scope_extension.rb +1 -0
- data/lib/graphql/schema/field.rb +621 -109
- data/lib/graphql/schema/field_extension.rb +89 -34
- data/lib/graphql/schema/find_inherited_value.rb +5 -3
- data/lib/graphql/schema/finder.rb +22 -8
- data/lib/graphql/schema/has_single_input_argument.rb +39 -6
- data/lib/graphql/schema/input_object.rb +40 -13
- data/lib/graphql/schema/interface.rb +33 -17
- data/lib/graphql/schema/introspection_system.rb +7 -3
- data/lib/graphql/schema/late_bound_type.rb +2 -2
- data/lib/graphql/schema/list.rb +15 -4
- data/lib/graphql/schema/loader.rb +23 -12
- data/lib/graphql/schema/member/base_dsl_methods.rb +58 -12
- data/lib/graphql/schema/member/build_type.rb +16 -5
- data/lib/graphql/schema/member/graphql_type_names.rb +10 -6
- data/lib/graphql/schema/member/has_arguments.rb +115 -48
- data/lib/graphql/schema/member/has_ast_node.rb +1 -0
- data/lib/graphql/schema/member/has_authorization.rb +5 -0
- data/lib/graphql/schema/member/has_dataloader.rb +91 -34
- data/lib/graphql/schema/member/has_deprecation_reason.rb +15 -2
- data/lib/graphql/schema/member/has_directives.rb +38 -10
- data/lib/graphql/schema/member/has_fields.rb +151 -70
- data/lib/graphql/schema/member/has_interfaces.rb +10 -2
- data/lib/graphql/schema/member/has_path.rb +14 -5
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +1 -0
- data/lib/graphql/schema/member/has_validators.rb +19 -4
- data/lib/graphql/schema/member/relay_shortcuts.rb +10 -2
- data/lib/graphql/schema/member/scoped.rb +14 -3
- data/lib/graphql/schema/member/type_system_helpers.rb +36 -6
- data/lib/graphql/schema/member/validates_input.rb +1 -0
- data/lib/graphql/schema/member.rb +9 -2
- data/lib/graphql/schema/mutation.rb +50 -46
- data/lib/graphql/schema/non_null.rb +21 -5
- data/lib/graphql/schema/object.rb +33 -12
- data/lib/graphql/schema/printer.rb +52 -31
- data/lib/graphql/schema/ractor_shareable.rb +6 -2
- data/lib/graphql/schema/relay_classic_mutation.rb +3 -3
- data/lib/graphql/schema/resolver/has_payload_type.rb +29 -7
- data/lib/graphql/schema/resolver.rb +156 -45
- data/lib/graphql/schema/scalar.rb +1 -0
- data/lib/graphql/schema/subscription.rb +67 -28
- data/lib/graphql/schema/timeout.rb +65 -25
- data/lib/graphql/schema/type_expression.rb +14 -5
- data/lib/graphql/schema/type_membership.rb +29 -10
- data/lib/graphql/schema/union.rb +4 -2
- data/lib/graphql/schema/unique_within_type.rb +24 -5
- data/lib/graphql/schema/validator/all_validator.rb +17 -9
- data/lib/graphql/schema/validator/allow_blank_validator.rb +8 -2
- data/lib/graphql/schema/validator/allow_null_validator.rb +8 -2
- data/lib/graphql/schema/validator/exclusion_validator.rb +14 -5
- data/lib/graphql/schema/validator/format_validator.rb +21 -10
- data/lib/graphql/schema/validator/inclusion_validator.rb +15 -6
- data/lib/graphql/schema/validator/length_validator.rb +23 -12
- data/lib/graphql/schema/validator/numericality_validator.rb +29 -16
- data/lib/graphql/schema/validator/required_validator.rb +45 -31
- data/lib/graphql/schema/validator.rb +89 -25
- data/lib/graphql/schema/visibility/migration.rb +14 -7
- data/lib/graphql/schema/visibility/profile.rb +20 -17
- data/lib/graphql/schema/visibility/visit.rb +12 -10
- data/lib/graphql/schema/visibility.rb +24 -20
- data/lib/graphql/schema/warden.rb +117 -31
- data/lib/graphql/schema/wrapper.rb +4 -1
- data/lib/graphql/schema.rb +1046 -300
- data/lib/graphql/static_validation/all_rules.rb +2 -1
- data/lib/graphql/static_validation/base_visitor.rb +48 -8
- data/lib/graphql/static_validation/definition_dependencies.rb +27 -7
- data/lib/graphql/static_validation/error.rb +3 -0
- data/lib/graphql/static_validation/interpreter_visitor.rb +1 -0
- data/lib/graphql/static_validation/literal_validator.rb +1 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +4 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +1 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +3 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +1 -0
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +3 -0
- data/lib/graphql/static_validation/rules/directives_are_defined_error.rb +1 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +3 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +3 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +9 -1
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +295 -134
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +14 -2
- data/lib/graphql/static_validation/rules/fragment_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_named.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_used.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_used_error.rb +1 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +3 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +3 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/not_single_subscription_error.rb +1 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +4 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +1 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid.rb +3 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid_error.rb +1 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +3 -0
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +4 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/subscription_root_exists_and_single_subscription_selection.rb +4 -1
- data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +3 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +3 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +207 -51
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +3 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +6 -3
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb +1 -0
- data/lib/graphql/static_validation/validation_context.rb +3 -2
- data/lib/graphql/static_validation/validation_timeout_error.rb +1 -0
- data/lib/graphql/static_validation/validator.rb +41 -16
- data/lib/graphql/static_validation.rb +1 -0
- data/lib/graphql/string_encoding_error.rb +1 -0
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +85 -65
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +10 -4
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +1 -0
- data/lib/graphql/subscriptions/event.rb +25 -6
- data/lib/graphql/subscriptions/serialize.rb +58 -19
- data/lib/graphql/subscriptions.rb +172 -46
- data/lib/graphql/testing/helpers.rb +17 -4
- data/lib/graphql/testing/mock_action_cable.rb +55 -33
- data/lib/graphql/testing.rb +1 -0
- data/lib/graphql/tracing/active_support_notifications_trace.rb +17 -9
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +2 -1
- data/lib/graphql/tracing/appoptics_trace.rb +2 -1
- data/lib/graphql/tracing/appoptics_tracing.rb +2 -1
- data/lib/graphql/tracing/appsignal_trace.rb +16 -7
- data/lib/graphql/tracing/appsignal_tracing.rb +7 -3
- data/lib/graphql/tracing/call_legacy_tracers.rb +1 -0
- data/lib/graphql/tracing/data_dog_trace.rb +17 -6
- data/lib/graphql/tracing/data_dog_tracing.rb +10 -3
- data/lib/graphql/tracing/detailed_trace/active_record_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace/memory_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace/redis_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace.rb +105 -42
- data/lib/graphql/tracing/legacy_hooks_trace.rb +5 -0
- data/lib/graphql/tracing/legacy_trace.rb +1 -0
- data/lib/graphql/tracing/monitor_trace.rb +17 -11
- data/lib/graphql/tracing/new_relic_trace.rb +17 -8
- data/lib/graphql/tracing/new_relic_tracing.rb +7 -3
- data/lib/graphql/tracing/notifications_trace.rb +11 -8
- data/lib/graphql/tracing/notifications_tracing.rb +23 -7
- data/lib/graphql/tracing/null_trace.rb +1 -0
- data/lib/graphql/tracing/perfetto_trace/trace_pb.rb +1 -0
- data/lib/graphql/tracing/perfetto_trace.rb +41 -19
- data/lib/graphql/tracing/platform_trace.rb +3 -1
- data/lib/graphql/tracing/platform_tracing.rb +16 -7
- data/lib/graphql/tracing/prometheus_trace/graphql_collector.rb +1 -0
- data/lib/graphql/tracing/prometheus_trace.rb +22 -13
- data/lib/graphql/tracing/prometheus_tracing.rb +1 -0
- data/lib/graphql/tracing/scout_trace.rb +10 -4
- data/lib/graphql/tracing/scout_tracing.rb +7 -3
- data/lib/graphql/tracing/sentry_trace.rb +12 -5
- data/lib/graphql/tracing/statsd_trace.rb +12 -6
- data/lib/graphql/tracing/statsd_tracing.rb +7 -1
- data/lib/graphql/tracing/trace.rb +231 -58
- data/lib/graphql/tracing.rb +25 -9
- data/lib/graphql/type_kinds.rb +2 -1
- data/lib/graphql/types/big_int.rb +1 -0
- data/lib/graphql/types/boolean.rb +1 -0
- data/lib/graphql/types/float.rb +1 -0
- data/lib/graphql/types/id.rb +1 -0
- data/lib/graphql/types/int.rb +2 -1
- data/lib/graphql/types/iso_8601_date.rb +21 -4
- data/lib/graphql/types/iso_8601_date_time.rb +33 -6
- data/lib/graphql/types/iso_8601_duration.rb +42 -9
- data/lib/graphql/types/json.rb +1 -0
- data/lib/graphql/types/relay/base_connection.rb +38 -32
- data/lib/graphql/types/relay/base_edge.rb +15 -9
- data/lib/graphql/types/relay/connection_behaviors.rb +19 -3
- data/lib/graphql/types/relay/edge_behaviors.rb +17 -4
- data/lib/graphql/types/relay/has_node_field.rb +6 -1
- data/lib/graphql/types/relay/has_nodes_field.rb +6 -1
- data/lib/graphql/types/relay/node.rb +1 -0
- data/lib/graphql/types/relay/node_behaviors.rb +5 -1
- data/lib/graphql/types/relay/page_info.rb +1 -0
- data/lib/graphql/types/relay/page_info_behaviors.rb +1 -0
- data/lib/graphql/types/relay.rb +4 -3
- data/lib/graphql/types/string.rb +1 -0
- data/lib/graphql/types.rb +1 -0
- data/lib/graphql/unauthorized_enum_value_error.rb +4 -1
- data/lib/graphql/unauthorized_error.rb +11 -4
- data/lib/graphql/unauthorized_field_error.rb +4 -1
- data/lib/graphql/unresolved_type_error.rb +16 -5
- data/lib/graphql/version.rb +2 -1
- data/lib/graphql.rb +37 -9
- data/readme.md +1 -1
- metadata +89 -5
- data/.yardopts +0 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require "graphql/schema/resolver/has_payload_type"
|
|
3
4
|
|
|
4
5
|
module GraphQL
|
|
@@ -16,8 +17,8 @@ module GraphQL
|
|
|
16
17
|
#
|
|
17
18
|
# A resolver's configuration may be overridden with other keywords in the `field(...)` call.
|
|
18
19
|
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
20
|
+
# See [GraphQL::Schema::Mutation](rdoc-ref:GraphQL::Schema::Mutation) for a concrete subclass of `Resolver`.
|
|
21
|
+
# `Resolver` is a replacement for the former `GraphQL::Function` API.
|
|
21
22
|
class Resolver
|
|
22
23
|
include Schema::Member::GraphQLTypeNames
|
|
23
24
|
# Really we only need description & comment from here, but:
|
|
@@ -31,9 +32,14 @@ module GraphQL
|
|
|
31
32
|
include Schema::Member::HasDataloader
|
|
32
33
|
extend Schema::Member::HasDeprecationReason
|
|
33
34
|
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
35
|
+
# **Parameters**
|
|
36
|
+
#
|
|
37
|
+
# - `object` (`Object`) — The application object that this field is being resolved on
|
|
38
|
+
# - `context` (`GraphQL::Query::Context`)
|
|
39
|
+
# - `field` (`GraphQL::Schema::Field`)
|
|
40
|
+
#
|
|
41
|
+
# :call-seq:
|
|
42
|
+
# initialize(Object object:, GraphQL::Query::Context context:, GraphQL::Schema::Field field:)
|
|
37
43
|
def initialize(object:, context:, field:)
|
|
38
44
|
@object = object
|
|
39
45
|
@context = context
|
|
@@ -48,13 +54,19 @@ module GraphQL
|
|
|
48
54
|
|
|
49
55
|
attr_accessor :exec_result, :exec_index, :field_resolve_step, :raw_arguments
|
|
50
56
|
|
|
51
|
-
#
|
|
57
|
+
# **Returns**
|
|
58
|
+
#
|
|
59
|
+
# - `Object` — The application object this field is being resolved on
|
|
52
60
|
attr_accessor :object
|
|
53
61
|
|
|
54
|
-
#
|
|
62
|
+
# **Returns**
|
|
63
|
+
#
|
|
64
|
+
# - `GraphQL::Query::Context`
|
|
55
65
|
attr_reader :context
|
|
56
66
|
|
|
57
|
-
#
|
|
67
|
+
# **Returns**
|
|
68
|
+
#
|
|
69
|
+
# - `GraphQL::Schema::Field`
|
|
58
70
|
attr_reader :field
|
|
59
71
|
|
|
60
72
|
attr_writer :prepared_arguments
|
|
@@ -132,8 +144,7 @@ module GraphQL
|
|
|
132
144
|
# This method is _actually_ called by the runtime,
|
|
133
145
|
# it does some preparation and then eventually calls
|
|
134
146
|
# the user-defined `#resolve` method.
|
|
135
|
-
#
|
|
136
|
-
def resolve_with_support(**args)
|
|
147
|
+
def resolve_with_support(**args) # :nodoc:
|
|
137
148
|
# First call the ready? hook which may raise
|
|
138
149
|
raw_ready_val = if !args.empty?
|
|
139
150
|
ready?(**args)
|
|
@@ -183,8 +194,7 @@ module GraphQL
|
|
|
183
194
|
end
|
|
184
195
|
end
|
|
185
196
|
|
|
186
|
-
|
|
187
|
-
def call_resolve(args_hash)
|
|
197
|
+
def call_resolve(args_hash) # :nodoc:
|
|
188
198
|
if !args_hash.empty?
|
|
189
199
|
public_send(self.class.resolve_method, **args_hash)
|
|
190
200
|
else
|
|
@@ -193,7 +203,13 @@ module GraphQL
|
|
|
193
203
|
end
|
|
194
204
|
|
|
195
205
|
# Do the work. Everything happens here.
|
|
196
|
-
#
|
|
206
|
+
#
|
|
207
|
+
# **Returns**
|
|
208
|
+
#
|
|
209
|
+
# - `Object` — An object corresponding to the return type
|
|
210
|
+
#
|
|
211
|
+
# :call-seq:
|
|
212
|
+
# resolve(**args) -> Object
|
|
197
213
|
def resolve(**args)
|
|
198
214
|
raise GraphQL::RequiredImplementationMissingError, "#{self.class.name}#resolve should execute the field's logic"
|
|
199
215
|
end
|
|
@@ -204,10 +220,21 @@ module GraphQL
|
|
|
204
220
|
# If it returns a lazy object (like a promise), it will be synced by GraphQL
|
|
205
221
|
# (but the resulting value won't be used).
|
|
206
222
|
#
|
|
207
|
-
#
|
|
208
|
-
#
|
|
209
|
-
#
|
|
210
|
-
#
|
|
223
|
+
# **Parameters**
|
|
224
|
+
#
|
|
225
|
+
# - `args` (`Hash`) — The input arguments, if there are any
|
|
226
|
+
#
|
|
227
|
+
# **Raises**
|
|
228
|
+
#
|
|
229
|
+
# - `GraphQL::ExecutionError` — To add an error to the response
|
|
230
|
+
# - `GraphQL::UnauthorizedError` — To signal an authorization failure
|
|
231
|
+
#
|
|
232
|
+
# **Returns**
|
|
233
|
+
#
|
|
234
|
+
# - `Boolean, early_return_data` — If `false`, execution will stop (and `early_return_data` will be returned instead, if present.)
|
|
235
|
+
#
|
|
236
|
+
# :call-seq:
|
|
237
|
+
# ready?(Hash **args) -> bool | early_return_data
|
|
211
238
|
def ready?(**args)
|
|
212
239
|
true
|
|
213
240
|
end
|
|
@@ -215,10 +242,22 @@ module GraphQL
|
|
|
215
242
|
# Called after arguments are loaded, but before resolving.
|
|
216
243
|
#
|
|
217
244
|
# Override it to check everything before calling the mutation.
|
|
218
|
-
#
|
|
219
|
-
#
|
|
220
|
-
#
|
|
221
|
-
#
|
|
245
|
+
#
|
|
246
|
+
# **Parameters**
|
|
247
|
+
#
|
|
248
|
+
# - `inputs` (`Hash`) — The input arguments
|
|
249
|
+
#
|
|
250
|
+
# **Raises**
|
|
251
|
+
#
|
|
252
|
+
# - `GraphQL::ExecutionError` — To add an error to the response
|
|
253
|
+
# - `GraphQL::UnauthorizedError` — To signal an authorization failure
|
|
254
|
+
#
|
|
255
|
+
# **Returns**
|
|
256
|
+
#
|
|
257
|
+
# - `Boolean, early_return_data` — If `false`, execution will stop (and `early_return_data` will be returned instead, if present.)
|
|
258
|
+
#
|
|
259
|
+
# :call-seq:
|
|
260
|
+
# authorized?(Hash **inputs) -> bool | early_return_data
|
|
222
261
|
def authorized?(**inputs)
|
|
223
262
|
arg_owner = @field # || self.class
|
|
224
263
|
args = context.types.arguments(arg_owner)
|
|
@@ -231,10 +270,16 @@ module GraphQL
|
|
|
231
270
|
|
|
232
271
|
# Called when an object loaded by `loads:` fails the `.authorized?` check for its resolved GraphQL object type.
|
|
233
272
|
#
|
|
234
|
-
# By default, the error is re-raised and passed along to
|
|
273
|
+
# By default, the error is re-raised and passed along to [Schema.unauthorized_object](rdoc-ref:Schema.unauthorized_object).
|
|
235
274
|
#
|
|
236
275
|
# Any value returned here will be used _instead of_ of the loaded object.
|
|
237
|
-
#
|
|
276
|
+
#
|
|
277
|
+
# **Parameters**
|
|
278
|
+
#
|
|
279
|
+
# - `err` (`GraphQL::UnauthorizedError`)
|
|
280
|
+
#
|
|
281
|
+
# :call-seq:
|
|
282
|
+
# unauthorized_object(GraphQL::UnauthorizedError err)
|
|
238
283
|
def unauthorized_object(err)
|
|
239
284
|
raise err
|
|
240
285
|
end
|
|
@@ -309,7 +354,13 @@ module GraphQL
|
|
|
309
354
|
end
|
|
310
355
|
|
|
311
356
|
# Default `:resolve` set below.
|
|
312
|
-
#
|
|
357
|
+
#
|
|
358
|
+
# **Returns**
|
|
359
|
+
#
|
|
360
|
+
# - `Symbol` — The method to call on instances of this object to resolve the field
|
|
361
|
+
#
|
|
362
|
+
# :call-seq:
|
|
363
|
+
# resolve_method(new_method) -> Symbol
|
|
313
364
|
def resolve_method(new_method = nil)
|
|
314
365
|
if new_method
|
|
315
366
|
@resolve_method = new_method
|
|
@@ -317,8 +368,8 @@ module GraphQL
|
|
|
317
368
|
@resolve_method || (superclass.respond_to?(:resolve_method) ? superclass.resolve_method : :resolve)
|
|
318
369
|
end
|
|
319
370
|
|
|
320
|
-
# Additional info injected into
|
|
321
|
-
#
|
|
371
|
+
# Additional info injected into [resolve](rdoc-ref:#resolve)
|
|
372
|
+
# See [GraphQL::Schema::Field#extras](rdoc-ref:GraphQL::Schema::Field#extras)
|
|
322
373
|
def extras(new_extras = nil)
|
|
323
374
|
if new_extras
|
|
324
375
|
@own_extras = new_extras
|
|
@@ -330,8 +381,14 @@ module GraphQL
|
|
|
330
381
|
# If `true` (default), then the return type for this resolver will be nullable.
|
|
331
382
|
# If `false`, then the return type is non-null.
|
|
332
383
|
#
|
|
333
|
-
#
|
|
334
|
-
#
|
|
384
|
+
# See [type](rdoc-ref:GraphQL::Schema::Resolver::type) which sets the return type of this field and accepts a `null:` option
|
|
385
|
+
#
|
|
386
|
+
# **Parameters**
|
|
387
|
+
#
|
|
388
|
+
# - `allow_null` (`Boolean`) — Whether or not the response can be null
|
|
389
|
+
#
|
|
390
|
+
# :call-seq:
|
|
391
|
+
# null(bool allow_null)
|
|
335
392
|
def null(allow_null = nil)
|
|
336
393
|
if !allow_null.nil?
|
|
337
394
|
@null = allow_null
|
|
@@ -351,10 +408,19 @@ module GraphQL
|
|
|
351
408
|
# Call this method to get the return type of the field,
|
|
352
409
|
# or use it as a configuration method to assign a return type
|
|
353
410
|
# instead of generating one.
|
|
354
|
-
# TODO unify with
|
|
355
|
-
#
|
|
356
|
-
#
|
|
357
|
-
#
|
|
411
|
+
# TODO unify with [null](rdoc-ref:GraphQL::Schema::Resolver::null)
|
|
412
|
+
#
|
|
413
|
+
# **Parameters**
|
|
414
|
+
#
|
|
415
|
+
# - `new_type` (`Class, Array<Class>, nil`) — If a type definition class is provided, it will be used as the return type of the field
|
|
416
|
+
# - `null` (`true, false`) — Whether or not the field may return `nil`
|
|
417
|
+
#
|
|
418
|
+
# **Returns**
|
|
419
|
+
#
|
|
420
|
+
# - `Class` — The type which this field returns.
|
|
421
|
+
#
|
|
422
|
+
# :call-seq:
|
|
423
|
+
# type(Class | Array[Class] | nil new_type, true | false null:) -> Class
|
|
358
424
|
def type(new_type = nil, null: nil)
|
|
359
425
|
if new_type
|
|
360
426
|
if null.nil?
|
|
@@ -374,7 +440,13 @@ module GraphQL
|
|
|
374
440
|
end
|
|
375
441
|
|
|
376
442
|
# Specifies the complexity of the field. Defaults to `1`
|
|
377
|
-
#
|
|
443
|
+
#
|
|
444
|
+
# **Returns**
|
|
445
|
+
#
|
|
446
|
+
# - `Integer, Proc`
|
|
447
|
+
#
|
|
448
|
+
# :call-seq:
|
|
449
|
+
# complexity(new_complexity) -> Integer | Proc
|
|
378
450
|
def complexity(new_complexity = nil)
|
|
379
451
|
if new_complexity
|
|
380
452
|
@complexity = new_complexity
|
|
@@ -386,7 +458,12 @@ module GraphQL
|
|
|
386
458
|
@broadcastable = new_broadcastable
|
|
387
459
|
end
|
|
388
460
|
|
|
389
|
-
#
|
|
461
|
+
# **Returns**
|
|
462
|
+
#
|
|
463
|
+
# - `Boolean, nil`
|
|
464
|
+
#
|
|
465
|
+
# :call-seq:
|
|
466
|
+
# broadcastable?() -> bool | nil
|
|
390
467
|
def broadcastable?
|
|
391
468
|
if defined?(@broadcastable)
|
|
392
469
|
@broadcastable
|
|
@@ -397,8 +474,17 @@ module GraphQL
|
|
|
397
474
|
|
|
398
475
|
# Get or set the `max_page_size:` which will be configured for fields using this resolver
|
|
399
476
|
# (`nil` means "unlimited max page size".)
|
|
400
|
-
#
|
|
401
|
-
#
|
|
477
|
+
#
|
|
478
|
+
# **Parameters**
|
|
479
|
+
#
|
|
480
|
+
# - `max_page_size` (`Integer, nil`) — Set a new value
|
|
481
|
+
#
|
|
482
|
+
# **Returns**
|
|
483
|
+
#
|
|
484
|
+
# - `Integer, nil` — The `max_page_size` assigned to fields that use this resolver
|
|
485
|
+
#
|
|
486
|
+
# :call-seq:
|
|
487
|
+
# max_page_size(new_max_page_size) -> Integer | nil
|
|
402
488
|
def max_page_size(new_max_page_size = NOT_CONFIGURED)
|
|
403
489
|
if new_max_page_size != NOT_CONFIGURED
|
|
404
490
|
@max_page_size = new_max_page_size
|
|
@@ -411,15 +497,29 @@ module GraphQL
|
|
|
411
497
|
end
|
|
412
498
|
end
|
|
413
499
|
|
|
414
|
-
#
|
|
500
|
+
# **Returns**
|
|
501
|
+
#
|
|
502
|
+
# - `Boolean` — `true` if this resolver or a superclass has an assigned `max_page_size`
|
|
503
|
+
#
|
|
504
|
+
# :call-seq:
|
|
505
|
+
# has_max_page_size?() -> bool
|
|
415
506
|
def has_max_page_size?
|
|
416
507
|
(!!defined?(@max_page_size)) || (superclass.respond_to?(:has_max_page_size?) && superclass.has_max_page_size?)
|
|
417
508
|
end
|
|
418
509
|
|
|
419
510
|
# Get or set the `default_page_size:` which will be configured for fields using this resolver
|
|
420
511
|
# (`nil` means "unlimited default page size".)
|
|
421
|
-
#
|
|
422
|
-
#
|
|
512
|
+
#
|
|
513
|
+
# **Parameters**
|
|
514
|
+
#
|
|
515
|
+
# - `default_page_size` (`Integer, nil`) — Set a new value
|
|
516
|
+
#
|
|
517
|
+
# **Returns**
|
|
518
|
+
#
|
|
519
|
+
# - `Integer, nil` — The `default_page_size` assigned to fields that use this resolver
|
|
520
|
+
#
|
|
521
|
+
# :call-seq:
|
|
522
|
+
# default_page_size(new_default_page_size) -> Integer | nil
|
|
423
523
|
def default_page_size(new_default_page_size = NOT_CONFIGURED)
|
|
424
524
|
if new_default_page_size != NOT_CONFIGURED
|
|
425
525
|
@default_page_size = new_default_page_size
|
|
@@ -432,7 +532,12 @@ module GraphQL
|
|
|
432
532
|
end
|
|
433
533
|
end
|
|
434
534
|
|
|
435
|
-
#
|
|
535
|
+
# **Returns**
|
|
536
|
+
#
|
|
537
|
+
# - `Boolean` — `true` if this resolver or a superclass has an assigned `default_page_size`
|
|
538
|
+
#
|
|
539
|
+
# :call-seq:
|
|
540
|
+
# has_default_page_size?() -> bool
|
|
436
541
|
def has_default_page_size?
|
|
437
542
|
(!!defined?(@default_page_size)) || (superclass.respond_to?(:has_default_page_size?) && superclass.has_default_page_size?)
|
|
438
543
|
end
|
|
@@ -444,23 +549,29 @@ module GraphQL
|
|
|
444
549
|
|
|
445
550
|
# Add an argument to this field's signature, but
|
|
446
551
|
# also add some preparation hook methods which will be used for this argument
|
|
447
|
-
#
|
|
552
|
+
# See [GraphQL::Schema::Argument](rdoc-ref:GraphQL::Schema::Argument) for the signature
|
|
448
553
|
def argument(*args, **kwargs, &block)
|
|
449
554
|
# Use `from_resolver: true` to short-circuit the InputObject's own `loads:` implementation
|
|
450
555
|
# so that we can support `#load_{x}` methods below.
|
|
556
|
+
args = args #: untyped
|
|
451
557
|
super(*args, from_resolver: true, **kwargs)
|
|
452
558
|
end
|
|
453
559
|
|
|
454
560
|
# Registers new extension
|
|
455
|
-
#
|
|
456
|
-
#
|
|
561
|
+
#
|
|
562
|
+
# **Parameters**
|
|
563
|
+
#
|
|
564
|
+
# - `extension` (`Class`) — Extension class
|
|
565
|
+
# - `options` (`Hash`) — Optional extension options
|
|
566
|
+
#
|
|
567
|
+
# :call-seq:
|
|
568
|
+
# extension(Class extension, Hash **options)
|
|
457
569
|
def extension(extension, **options)
|
|
458
570
|
@own_extensions ||= []
|
|
459
571
|
@own_extensions << {extension => options}
|
|
460
572
|
end
|
|
461
573
|
|
|
462
|
-
#
|
|
463
|
-
def extensions
|
|
574
|
+
def extensions # :nodoc:
|
|
464
575
|
own_exts = @own_extensions
|
|
465
576
|
# Jump through some hoops to avoid creating arrays when we don't actually need them
|
|
466
577
|
if superclass.respond_to?(:extensions)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
@@ -17,8 +18,7 @@ module GraphQL
|
|
|
17
18
|
NO_UPDATE = :no_update
|
|
18
19
|
null false
|
|
19
20
|
|
|
20
|
-
#
|
|
21
|
-
def initialize(object:, context:, field:)
|
|
21
|
+
def initialize(object:, context:, field:) # :nodoc:
|
|
22
22
|
super
|
|
23
23
|
# Figure out whether this is an update or an initial subscription
|
|
24
24
|
@mode = context.query.subscription_update? ? :update : :subscribe
|
|
@@ -30,8 +30,7 @@ module GraphQL
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
#
|
|
34
|
-
def call_resolve(args_hash)
|
|
33
|
+
def call_resolve(args_hash) # :nodoc:
|
|
35
34
|
if @field_resolve_step.nil?
|
|
36
35
|
super
|
|
37
36
|
else
|
|
@@ -60,8 +59,7 @@ module GraphQL
|
|
|
60
59
|
end
|
|
61
60
|
end
|
|
62
61
|
|
|
63
|
-
#
|
|
64
|
-
def resolve_with_support(**args)
|
|
62
|
+
def resolve_with_support(**args) # :nodoc:
|
|
65
63
|
@original_arguments = args # before `loads:` have been run
|
|
66
64
|
result = nil
|
|
67
65
|
unsubscribed = true
|
|
@@ -86,9 +84,9 @@ module GraphQL
|
|
|
86
84
|
end
|
|
87
85
|
end
|
|
88
86
|
|
|
89
|
-
# Implement the
|
|
87
|
+
# Implement the [resolve](rdoc-ref:#resolve) API.
|
|
90
88
|
# You can implement this if you want code to run for _both_ the initial subscription
|
|
91
|
-
# and for later updates. Or, implement
|
|
89
|
+
# and for later updates. Or, implement [subscribe](rdoc-ref:#subscribe) and [update](rdoc-ref:#update)
|
|
92
90
|
def resolve(**args)
|
|
93
91
|
# Dispatch based on `@mode`, which will raise a `NoMethodError` if we ever
|
|
94
92
|
# have an unexpected `@mode`
|
|
@@ -96,8 +94,7 @@ module GraphQL
|
|
|
96
94
|
end
|
|
97
95
|
|
|
98
96
|
# Wrap the user-defined `#subscribe` hook
|
|
99
|
-
#
|
|
100
|
-
def resolve_subscribe(**args)
|
|
97
|
+
def resolve_subscribe(**args) # :nodoc:
|
|
101
98
|
ret_val = !args.empty? ? subscribe(**args) : subscribe
|
|
102
99
|
if ret_val == :no_response
|
|
103
100
|
context.skip
|
|
@@ -114,8 +111,7 @@ module GraphQL
|
|
|
114
111
|
end
|
|
115
112
|
|
|
116
113
|
# Wrap the user-provided `#update` hook
|
|
117
|
-
#
|
|
118
|
-
def resolve_update(**args)
|
|
114
|
+
def resolve_update(**args) # :nodoc:
|
|
119
115
|
ret_val = !args.empty? ? update(**args) : update
|
|
120
116
|
if ret_val == NO_UPDATE
|
|
121
117
|
context.namespace(:subscriptions)[:no_update] = true
|
|
@@ -126,7 +122,7 @@ module GraphQL
|
|
|
126
122
|
end
|
|
127
123
|
|
|
128
124
|
# The default implementation returns the root object.
|
|
129
|
-
# Override it to return
|
|
125
|
+
# Override it to return [NO_UPDATE](rdoc-ref:NO_UPDATE) if you want to
|
|
130
126
|
# skip updates sometimes. Or override it to return a different object.
|
|
131
127
|
def update(args = {})
|
|
132
128
|
object
|
|
@@ -143,8 +139,17 @@ module GraphQL
|
|
|
143
139
|
end
|
|
144
140
|
|
|
145
141
|
# Call this to halt execution and remove this subscription from the system
|
|
146
|
-
#
|
|
147
|
-
#
|
|
142
|
+
#
|
|
143
|
+
# **Parameters**
|
|
144
|
+
#
|
|
145
|
+
# - `update_value` (`Object`) — if present, deliver this update before unsubscribing
|
|
146
|
+
#
|
|
147
|
+
# **Returns**
|
|
148
|
+
#
|
|
149
|
+
# - `void`
|
|
150
|
+
#
|
|
151
|
+
# :call-seq:
|
|
152
|
+
# unsubscribe(Object update_value) -> void
|
|
148
153
|
def unsubscribe(update_value = nil)
|
|
149
154
|
context.namespace(:subscriptions)[:unsubscribed] = true
|
|
150
155
|
err = EarlyUnsubscribe.new
|
|
@@ -158,9 +163,18 @@ module GraphQL
|
|
|
158
163
|
|
|
159
164
|
# Call this method to provide a new subscription_scope; OR
|
|
160
165
|
# call it without an argument to get the subscription_scope
|
|
161
|
-
#
|
|
162
|
-
#
|
|
163
|
-
#
|
|
166
|
+
#
|
|
167
|
+
# **Parameters**
|
|
168
|
+
#
|
|
169
|
+
# - `new_scope` (`Symbol`)
|
|
170
|
+
# - `optional` (`Boolean`) — If true, then don't require `scope:` to be provided to updates to this subscription.
|
|
171
|
+
#
|
|
172
|
+
# **Returns**
|
|
173
|
+
#
|
|
174
|
+
# - `Symbol`
|
|
175
|
+
#
|
|
176
|
+
# :call-seq:
|
|
177
|
+
# subscription_scope(Symbol new_scope, bool optional:) -> Symbol
|
|
164
178
|
def self.subscription_scope(new_scope = NOT_CONFIGURED, optional: false)
|
|
165
179
|
if new_scope != NOT_CONFIGURED
|
|
166
180
|
@subscription_scope = new_scope
|
|
@@ -188,14 +202,23 @@ module GraphQL
|
|
|
188
202
|
# In that implementation, only `.trigger` calls with _exact matches_ result in updates to subscribers.
|
|
189
203
|
#
|
|
190
204
|
# To implement a filtered stream-type subscription flow, override this method to return a string with field name and subscription scope.
|
|
191
|
-
# Then, implement
|
|
205
|
+
# Then, implement [update](rdoc-ref:#update) to compare its arguments to the current `object` and return [NO_UPDATE](rdoc-ref:NO_UPDATE) when an
|
|
192
206
|
# update should be filtered out.
|
|
193
207
|
#
|
|
194
|
-
#
|
|
195
|
-
#
|
|
196
|
-
#
|
|
197
|
-
#
|
|
198
|
-
#
|
|
208
|
+
# See [update](rdoc-ref:#update) for how to skip updates when an event comes with a matching topic.
|
|
209
|
+
#
|
|
210
|
+
# **Parameters**
|
|
211
|
+
#
|
|
212
|
+
# - `arguments` (`Hash<String => Object>`) — The arguments for this topic, in GraphQL-style (camelized strings)
|
|
213
|
+
# - `field` (`GraphQL::Schema::Field`)
|
|
214
|
+
# - `scope` (`Object, nil`) — A value corresponding to `.trigger(... scope:)` (for updates) or the `subscription_scope` found in `context` (for initial subscriptions).
|
|
215
|
+
#
|
|
216
|
+
# **Returns**
|
|
217
|
+
#
|
|
218
|
+
# - `String` — An identifier corresponding to a stream of updates
|
|
219
|
+
#
|
|
220
|
+
# :call-seq:
|
|
221
|
+
# topic_for(Hash[String, Object] arguments:, GraphQL::Schema::Field field:, Object | nil scope:) -> String
|
|
199
222
|
def self.topic_for(arguments:, field:, scope:)
|
|
200
223
|
Subscriptions::Serialize.dump_recursive([scope, field.graphql_name, arguments])
|
|
201
224
|
end
|
|
@@ -205,10 +228,16 @@ module GraphQL
|
|
|
205
228
|
# but if you need to commit the subscription during `#subscribe`, you can call it there.
|
|
206
229
|
# (This method also sets a flag showing that this subscription was already written.)
|
|
207
230
|
#
|
|
208
|
-
# If you call this method yourself, you may also need to
|
|
231
|
+
# If you call this method yourself, you may also need to [unsubscribe](rdoc-ref:#unsubscribe)
|
|
209
232
|
# or call `subscriptions.delete_subscription` to clean up the database if the query crashes with an error
|
|
210
233
|
# later in execution.
|
|
211
|
-
#
|
|
234
|
+
#
|
|
235
|
+
# **Returns**
|
|
236
|
+
#
|
|
237
|
+
# - `void`
|
|
238
|
+
#
|
|
239
|
+
# :call-seq:
|
|
240
|
+
# write_subscription() -> void
|
|
212
241
|
def write_subscription
|
|
213
242
|
if subscription_written?
|
|
214
243
|
raise GraphQL::Error, "`write_subscription` was called but `#{self.class}#subscription_written?` is already true. Remove a call to `write subscription`."
|
|
@@ -219,12 +248,22 @@ module GraphQL
|
|
|
219
248
|
nil
|
|
220
249
|
end
|
|
221
250
|
|
|
222
|
-
#
|
|
251
|
+
# **Returns**
|
|
252
|
+
#
|
|
253
|
+
# - `Boolean` — `true` if [write subscription](rdoc-ref:#write_subscription) was called already
|
|
254
|
+
#
|
|
255
|
+
# :call-seq:
|
|
256
|
+
# subscription_written?() -> bool
|
|
223
257
|
def subscription_written?
|
|
224
258
|
@subscription_written
|
|
225
259
|
end
|
|
226
260
|
|
|
227
|
-
#
|
|
261
|
+
# **Returns**
|
|
262
|
+
#
|
|
263
|
+
# - `Subscriptions::Event` — This object is used as a representation of this subscription for the backend
|
|
264
|
+
#
|
|
265
|
+
# :call-seq:
|
|
266
|
+
# event() -> Subscriptions::Event
|
|
228
267
|
def event
|
|
229
268
|
@event ||= begin
|
|
230
269
|
if @original_arguments.nil? && @field_resolve_step
|