graphql 2.6.9 → 2.6.14
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 +3 -2
- 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 +45 -16
- 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 +98 -44
- 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 +288 -168
- data/lib/graphql/execution/finalize.rb +12 -6
- data/lib/graphql/execution/input_values.rb +5 -2
- 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 +72 -25
- data/lib/graphql/execution/interpreter.rb +18 -7
- 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 +38 -13
- data/lib/graphql/execution/resolve_type_step.rb +2 -1
- data/lib/graphql/execution/runner.rb +32 -15
- 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 +14 -0
- data/lib/graphql/float_encoding_error.rb +33 -0
- 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 +16 -8
- data/lib/graphql/language/nodes.rb +2094 -419
- data/lib/graphql/language/parser.rb +29 -18
- 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 +15 -9
- 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 +24 -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 +164 -27
- 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 -16
- 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 +17 -1
- data/lib/graphql/query/variables.rb +9 -2
- data/lib/graphql/query.rb +195 -50
- 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 +69 -50
- data/lib/graphql/schema/always_visible.rb +1 -0
- data/lib/graphql/schema/argument.rb +279 -45
- 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 +507 -178
- 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 +33 -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 +622 -110
- 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 +21 -7
- data/lib/graphql/schema/member/graphql_type_names.rb +10 -6
- data/lib/graphql/schema/member/has_arguments.rb +112 -49
- 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 +45 -11
- data/lib/graphql/schema/member/has_fields.rb +151 -70
- data/lib/graphql/schema/member/has_interfaces.rb +8 -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 +44 -15
- 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 +73 -19
- 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 +1052 -304
- data/lib/graphql/static_validation/all_rules.rb +2 -1
- data/lib/graphql/static_validation/base_visitor.rb +59 -9
- 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 +355 -157
- 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 +43 -5
- 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 +89 -23
- 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 +25 -6
- 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 +19 -4
- 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 +39 -9
- data/readme.md +1 -1
- metadata +91 -5
- data/.yardopts +0 -5
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Execution
|
|
5
6
|
class Interpreter
|
|
6
7
|
# A container for metadata regarding arguments present in a GraphQL query.
|
|
7
|
-
#
|
|
8
|
+
# See [Interpreter::Arguments#argument_values](rdoc-ref:Interpreter::Arguments#argument_values) for a hash of these objects.
|
|
8
9
|
class ArgumentValue
|
|
9
10
|
def initialize(definition:, value:, original_value:, default_used:)
|
|
10
11
|
@definition = definition
|
|
@@ -13,16 +14,27 @@ module GraphQL
|
|
|
13
14
|
@default_used = default_used
|
|
14
15
|
end
|
|
15
16
|
|
|
16
|
-
#
|
|
17
|
+
# **Returns**
|
|
18
|
+
#
|
|
19
|
+
# - `Object` — The Ruby-ready value for this Argument
|
|
17
20
|
attr_reader :value
|
|
18
21
|
|
|
19
|
-
#
|
|
22
|
+
# **Returns**
|
|
23
|
+
#
|
|
24
|
+
# - `Object` — The value of this argument _before_ `prepare` is applied.
|
|
20
25
|
attr_reader :original_value
|
|
21
26
|
|
|
22
|
-
#
|
|
27
|
+
# **Returns**
|
|
28
|
+
#
|
|
29
|
+
# - `GraphQL::Schema::Argument` — The definition instance for this argument
|
|
23
30
|
attr_reader :definition
|
|
24
31
|
|
|
25
|
-
#
|
|
32
|
+
# **Returns**
|
|
33
|
+
#
|
|
34
|
+
# - `Boolean` — `true` if the schema-defined `default_value:` was applied in this case. (No client-provided value was present.)
|
|
35
|
+
#
|
|
36
|
+
# :call-seq:
|
|
37
|
+
# default_used?() -> bool
|
|
26
38
|
def default_used?
|
|
27
39
|
@default_used
|
|
28
40
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Execution
|
|
@@ -8,7 +9,7 @@ module GraphQL
|
|
|
8
9
|
# This object is immutable so that the runtime code can be sure that
|
|
9
10
|
# modifications don't leak from one use to another
|
|
10
11
|
#
|
|
11
|
-
#
|
|
12
|
+
# See [GraphQL::Query#arguments_for](rdoc-ref:GraphQL::Query#arguments_for) to get access to these objects.
|
|
12
13
|
class Arguments
|
|
13
14
|
extend Forwardable
|
|
14
15
|
include GraphQL::Dig
|
|
@@ -16,11 +17,18 @@ module GraphQL
|
|
|
16
17
|
# The Ruby-style arguments hash, ready for a resolver.
|
|
17
18
|
# This hash is the one used at runtime.
|
|
18
19
|
#
|
|
19
|
-
#
|
|
20
|
+
# **Returns**
|
|
21
|
+
#
|
|
22
|
+
# - `Hash<Symbol, Object>`
|
|
20
23
|
attr_reader :keyword_arguments
|
|
21
24
|
|
|
22
|
-
#
|
|
23
|
-
#
|
|
25
|
+
# **Parameters**
|
|
26
|
+
#
|
|
27
|
+
# - `argument_values` (`nil, Hash{Symbol => ArgumentValue}`)
|
|
28
|
+
# - `keyword_arguments` (`nil, Hash{Symbol => Object}`)
|
|
29
|
+
#
|
|
30
|
+
# :call-seq:
|
|
31
|
+
# initialize(nil | Hash[Symbol, Object] keyword_arguments:, nil | Hash[Symbol, ArgumentValue] argument_values:)
|
|
24
32
|
def initialize(keyword_arguments: nil, argument_values:)
|
|
25
33
|
@empty = argument_values.nil? || argument_values.empty?
|
|
26
34
|
# This is only present when `extras` have been merged in:
|
|
@@ -52,7 +60,9 @@ module GraphQL
|
|
|
52
60
|
freeze
|
|
53
61
|
end
|
|
54
62
|
|
|
55
|
-
#
|
|
63
|
+
# **Returns**
|
|
64
|
+
#
|
|
65
|
+
# - `Hash{Symbol => ArgumentValue}`
|
|
56
66
|
attr_reader :argument_values
|
|
57
67
|
|
|
58
68
|
def empty?
|
|
@@ -70,10 +80,15 @@ module GraphQL
|
|
|
70
80
|
#
|
|
71
81
|
# This is called by the runtime to implement field `extras: [...]`
|
|
72
82
|
#
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
|
|
83
|
+
#
|
|
84
|
+
# **Parameters**
|
|
85
|
+
#
|
|
86
|
+
# - `extra_args` (`Hash<Symbol => Object>`)
|
|
87
|
+
#
|
|
88
|
+
# **Returns**
|
|
89
|
+
#
|
|
90
|
+
# - `Interpreter::Arguments`
|
|
91
|
+
def merge_extras(extra_args) # :nodoc:
|
|
77
92
|
self.class.new(
|
|
78
93
|
argument_values: argument_values,
|
|
79
94
|
keyword_arguments: keyword_arguments.merge(extra_args)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Execution
|
|
@@ -36,7 +37,7 @@ module GraphQL
|
|
|
36
37
|
@storage[argument_owner][nil][ast_node]
|
|
37
38
|
end
|
|
38
39
|
|
|
39
|
-
#
|
|
40
|
+
# **Yields:** [Interpreter::Arguments, Lazy<Interpreter::Arguments>] The finally-loaded arguments
|
|
40
41
|
def dataload_for(ast_node, argument_owner, parent_object, &block)
|
|
41
42
|
# First, normalize all AST or Ruby values to a plain Ruby hash
|
|
42
43
|
arg_storage = @storage[argument_owner][parent_object]
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Execution
|
|
5
6
|
class Interpreter
|
|
6
7
|
module Resolve
|
|
7
8
|
# Continue field results in `results` until there's nothing else to continue.
|
|
8
|
-
#
|
|
9
|
-
#
|
|
9
|
+
# **Deprecated:** Call `dataloader.run` instead
|
|
10
|
+
#
|
|
11
|
+
# **Returns**
|
|
12
|
+
#
|
|
13
|
+
# - `void`
|
|
14
|
+
#
|
|
15
|
+
# :call-seq:
|
|
16
|
+
# resolve_all(results, dataloader) -> void
|
|
10
17
|
def self.resolve_all(results, dataloader)
|
|
11
|
-
|
|
18
|
+
backtrace = caller(1, 5) #: as !nil
|
|
19
|
+
warn "#{self}.#{__method__} is deprecated; Use `dataloader.run` instead.#{backtrace.map { |l| "\n #{l}"}.join}"
|
|
12
20
|
dataloader.append_job { resolve(results, dataloader) }
|
|
13
21
|
nil
|
|
14
22
|
end
|
|
15
23
|
|
|
16
|
-
#
|
|
24
|
+
# **Deprecated:** Call `dataloader.run` instead
|
|
17
25
|
def self.resolve_each_depth(lazies_at_depth, dataloader)
|
|
18
|
-
|
|
26
|
+
backtrace = caller(1, 5) #: as !nil
|
|
27
|
+
warn "#{self}.#{__method__} is deprecated; Use `dataloader.run` instead.#{backtrace.map { |l| "\n #{l}"}.join}"
|
|
19
28
|
|
|
20
|
-
smallest_depth = nil
|
|
29
|
+
smallest_depth = nil #: Integer?
|
|
21
30
|
lazies_at_depth.each_key do |depth_key|
|
|
22
31
|
smallest_depth ||= depth_key
|
|
23
32
|
if depth_key < smallest_depth
|
|
@@ -39,9 +48,10 @@ module GraphQL
|
|
|
39
48
|
nil
|
|
40
49
|
end
|
|
41
50
|
|
|
42
|
-
#
|
|
51
|
+
# **Deprecated:** Call `dataloader.run` instead
|
|
43
52
|
def self.resolve(results, dataloader)
|
|
44
|
-
|
|
53
|
+
backtrace = caller(1, 5) #: as !nil
|
|
54
|
+
warn "#{self}.#{__method__} is deprecated; Use `dataloader.run` instead.#{backtrace.map { |l| "\n #{l}"}.join}"
|
|
45
55
|
# There might be pending jobs here that _will_ write lazies
|
|
46
56
|
# into the result hash. We should run them out, so we
|
|
47
57
|
# can be sure that all lazies will be present in the result hashes.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Execution
|
|
@@ -54,7 +55,9 @@ module GraphQL
|
|
|
54
55
|
attr_reader :graphql_parent, :graphql_result_name, :graphql_is_non_null_in_parent,
|
|
55
56
|
:graphql_application_value, :graphql_result_type, :graphql_selections, :graphql_is_eager, :ast_node, :graphql_arguments, :graphql_field
|
|
56
57
|
|
|
57
|
-
#
|
|
58
|
+
# **Returns**
|
|
59
|
+
#
|
|
60
|
+
# - `Hash` — Plain-Ruby result data (`@graphql_metadata` contains Result wrapper objects)
|
|
58
61
|
attr_accessor :graphql_result_data
|
|
59
62
|
end
|
|
60
63
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require "graphql/execution/interpreter/runtime/graphql_result"
|
|
3
4
|
|
|
4
5
|
module GraphQL
|
|
@@ -7,8 +8,7 @@ module GraphQL
|
|
|
7
8
|
# I think it would be even better if we could somehow make
|
|
8
9
|
# `continue_field` not recursive. "Trampolining" it somehow.
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
-
class Runtime
|
|
11
|
+
class Runtime # :nodoc:
|
|
12
12
|
class CurrentState
|
|
13
13
|
def initialize
|
|
14
14
|
@current_field = nil
|
|
@@ -26,13 +26,19 @@ module GraphQL
|
|
|
26
26
|
:current_arguments, :current_field, :was_authorized_by_scope_items
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
#
|
|
29
|
+
# **Returns**
|
|
30
|
+
#
|
|
31
|
+
# - `GraphQL::Query`
|
|
30
32
|
attr_reader :query
|
|
31
33
|
|
|
32
|
-
#
|
|
34
|
+
# **Returns**
|
|
35
|
+
#
|
|
36
|
+
# - `Class<GraphQL::Schema>`
|
|
33
37
|
attr_reader :schema
|
|
34
38
|
|
|
35
|
-
#
|
|
39
|
+
# **Returns**
|
|
40
|
+
#
|
|
41
|
+
# - `GraphQL::Query::Context`
|
|
36
42
|
attr_reader :context
|
|
37
43
|
|
|
38
44
|
def initialize(query:)
|
|
@@ -63,7 +69,12 @@ module GraphQL
|
|
|
63
69
|
"#<#{self.class.name} response=#{@response.inspect}>"
|
|
64
70
|
end
|
|
65
71
|
|
|
66
|
-
#
|
|
72
|
+
# **Returns**
|
|
73
|
+
#
|
|
74
|
+
# - `void`
|
|
75
|
+
#
|
|
76
|
+
# :call-seq:
|
|
77
|
+
# run_eager() -> void
|
|
67
78
|
def run_eager
|
|
68
79
|
root_type = query.root_type
|
|
69
80
|
case query
|
|
@@ -138,7 +149,7 @@ module GraphQL
|
|
|
138
149
|
else
|
|
139
150
|
@response = GraphQLResultArray.new(nil, root_type, nil, nil, false, selections, false, ast_node, nil, nil)
|
|
140
151
|
@response.base_path = base_path
|
|
141
|
-
idx = nil
|
|
152
|
+
idx = nil #: Integer?
|
|
142
153
|
object.each do |inner_value|
|
|
143
154
|
idx ||= 0
|
|
144
155
|
this_idx = idx
|
|
@@ -209,6 +220,7 @@ module GraphQL
|
|
|
209
220
|
end
|
|
210
221
|
end
|
|
211
222
|
|
|
223
|
+
#: (untyped, untyped, untyped, untyped, Array[untyped]?, untyped, untyped) -> untyped
|
|
212
224
|
def gather_selections(graphql_response, owner_object, owner_type, selections, selections_to_run, selections_by_name, ordered_result_keys)
|
|
213
225
|
selections.each do |node|
|
|
214
226
|
if node.is_a?(GraphQL::Language::Nodes::Field)
|
|
@@ -242,7 +254,7 @@ module GraphQL
|
|
|
242
254
|
if selections_to_run
|
|
243
255
|
selections_to_run << next_selections
|
|
244
256
|
else
|
|
245
|
-
selections_to_run = []
|
|
257
|
+
selections_to_run = [] #: Array[untyped]
|
|
246
258
|
selections_to_run << selections_by_name
|
|
247
259
|
selections_to_run << next_selections
|
|
248
260
|
end
|
|
@@ -253,7 +265,10 @@ module GraphQL
|
|
|
253
265
|
case node
|
|
254
266
|
when GraphQL::Language::Nodes::InlineFragment
|
|
255
267
|
if node.type
|
|
256
|
-
type_defn = query.types.type(
|
|
268
|
+
type_defn = query.types.type(
|
|
269
|
+
node.type #: as !nil
|
|
270
|
+
.name
|
|
271
|
+
)
|
|
257
272
|
|
|
258
273
|
if query.types.possible_types(type_defn).include?(owner_type)
|
|
259
274
|
result = gather_selections(graphql_response, owner_object, owner_type, node.selections, selections_to_run, next_selections, ordered_result_keys)
|
|
@@ -287,7 +302,12 @@ module GraphQL
|
|
|
287
302
|
|
|
288
303
|
NO_ARGS = GraphQL::EmptyObjects::EMPTY_HASH
|
|
289
304
|
|
|
290
|
-
#
|
|
305
|
+
# **Returns**
|
|
306
|
+
#
|
|
307
|
+
# - `void`
|
|
308
|
+
#
|
|
309
|
+
# :call-seq:
|
|
310
|
+
# evaluate_selections(gathered_selections, selections_result, target_result, runtime_state) -> void
|
|
291
311
|
def evaluate_selections(gathered_selections, selections_result, target_result, runtime_state) # rubocop:disable Metrics/ParameterLists
|
|
292
312
|
runtime_state ||= get_current_runtime_state
|
|
293
313
|
runtime_state.current_result_name = nil
|
|
@@ -325,7 +345,12 @@ module GraphQL
|
|
|
325
345
|
end
|
|
326
346
|
end
|
|
327
347
|
|
|
328
|
-
#
|
|
348
|
+
# **Returns**
|
|
349
|
+
#
|
|
350
|
+
# - `void`
|
|
351
|
+
#
|
|
352
|
+
# :call-seq:
|
|
353
|
+
# evaluate_selection(result_name, field_ast_nodes_or_ast_node, selections_result) -> void
|
|
329
354
|
def evaluate_selection(result_name, field_ast_nodes_or_ast_node, selections_result) # rubocop:disable Metrics/ParameterLists
|
|
330
355
|
return if selections_result.graphql_dead
|
|
331
356
|
# As a performance optimization, the hash key will be a `Node` if
|
|
@@ -374,6 +399,7 @@ module GraphQL
|
|
|
374
399
|
end
|
|
375
400
|
end
|
|
376
401
|
|
|
402
|
+
#: (untyped, untyped, untyped, Array[untyped]?, untyped, untyped, untyped, untyped) -> untyped
|
|
377
403
|
def evaluate_selection_with_args(arguments, field_defn, ast_node, field_ast_nodes, object, result_name, selection_result, runtime_state) # rubocop:disable Metrics/ParameterLists
|
|
378
404
|
after_lazy(arguments, field: field_defn, ast_node: ast_node, owner_object: object, arguments: arguments, result_name: result_name, result: selection_result, runtime_state: runtime_state) do |resolved_arguments, runtime_state|
|
|
379
405
|
if resolved_arguments.is_a?(GraphQL::ExecutionError) || resolved_arguments.is_a?(GraphQL::UnauthorizedError)
|
|
@@ -405,7 +431,7 @@ module GraphQL
|
|
|
405
431
|
extra_args[:path] = current_path
|
|
406
432
|
when :lookahead
|
|
407
433
|
if !field_ast_nodes
|
|
408
|
-
field_ast_nodes = [ast_node]
|
|
434
|
+
field_ast_nodes = [ast_node] #: Array[untyped]
|
|
409
435
|
end
|
|
410
436
|
|
|
411
437
|
extra_args[:lookahead] = Execution::Lookahead.new(
|
|
@@ -556,9 +582,13 @@ module GraphQL
|
|
|
556
582
|
set_result(selection_result, result_name, nil, false, is_non_null) do
|
|
557
583
|
# When this comes from a list item, use the parent object:
|
|
558
584
|
is_from_array = selection_result.is_a?(GraphQLResultArray)
|
|
559
|
-
|
|
585
|
+
parent_result = selection_result
|
|
586
|
+
until parent_result.is_a?(GraphQLResultHash)
|
|
587
|
+
parent_result = parent_result.graphql_parent
|
|
588
|
+
end
|
|
589
|
+
parent_type = parent_result.graphql_result_type
|
|
560
590
|
# This block is called if `result_name` is not dead. (Maybe a previous invalid nil caused it be marked dead.)
|
|
561
|
-
err = parent_type
|
|
591
|
+
err = parent_type.const_get(:InvalidNullError).new(parent_type, field, ast_node, is_from_array: is_from_array)
|
|
562
592
|
schema.type_error(err, context)
|
|
563
593
|
end
|
|
564
594
|
else
|
|
@@ -619,7 +649,9 @@ module GraphQL
|
|
|
619
649
|
when Array
|
|
620
650
|
# It's an array full of execution errors; add them all.
|
|
621
651
|
if !value.empty? && value.all?(GraphQL::ExecutionError)
|
|
622
|
-
|
|
652
|
+
list_type = field && field.type
|
|
653
|
+
list_type = list_type.of_type if list_type && list_type.non_null?
|
|
654
|
+
list_type_at_all = list_type && list_type.list?
|
|
623
655
|
if selection_result.nil? || !selection_result.graphql_dead
|
|
624
656
|
value.each_with_index do |error, index|
|
|
625
657
|
error.ast_node ||= ast_node
|
|
@@ -627,7 +659,7 @@ module GraphQL
|
|
|
627
659
|
context.errors << error
|
|
628
660
|
end
|
|
629
661
|
if selection_result
|
|
630
|
-
if list_type_at_all
|
|
662
|
+
if list_type_at_all && !list_type.of_type.non_null?
|
|
631
663
|
result_without_errors = value.map { |v| v.is_a?(GraphQL::ExecutionError) ? nil : v }
|
|
632
664
|
set_result(selection_result, result_name, result_without_errors, false, is_non_null)
|
|
633
665
|
else
|
|
@@ -655,7 +687,12 @@ module GraphQL
|
|
|
655
687
|
#
|
|
656
688
|
# Location information from `path` and `ast_node`.
|
|
657
689
|
#
|
|
658
|
-
#
|
|
690
|
+
# **Returns**
|
|
691
|
+
#
|
|
692
|
+
# - `Lazy, Array, Hash, Object` — Lazy, Array, and Hash are all traversed to resolve lazy values later
|
|
693
|
+
#
|
|
694
|
+
# :call-seq:
|
|
695
|
+
# continue_field(value, owner_type, field, current_type, ast_node, next_selections, is_non_null, owner_object, arguments, result_name, selection_result, was_scoped, runtime_state) -> Lazy | Array | Hash | Object
|
|
659
696
|
def continue_field(value, owner_type, field, current_type, ast_node, next_selections, is_non_null, owner_object, arguments, result_name, selection_result, was_scoped, runtime_state) # rubocop:disable Metrics/ParameterLists
|
|
660
697
|
if current_type.non_null?
|
|
661
698
|
current_type = current_type.of_type
|
|
@@ -700,7 +737,7 @@ module GraphQL
|
|
|
700
737
|
possible_types = query.types.possible_types(current_type)
|
|
701
738
|
if !possible_types.include?(resolved_type)
|
|
702
739
|
parent_type = field.owner_type
|
|
703
|
-
err_class = current_type
|
|
740
|
+
err_class = current_type.const_get(:UnresolvedTypeError)
|
|
704
741
|
type_error = err_class.new(resolved_value, field, parent_type, resolved_type, possible_types)
|
|
705
742
|
schema.type_error(type_error, context)
|
|
706
743
|
set_result(selection_result, result_name, nil, false, is_non_null)
|
|
@@ -747,7 +784,7 @@ module GraphQL
|
|
|
747
784
|
inner_type_non_null = inner_type.non_null?
|
|
748
785
|
response_list = GraphQLResultArray.new(result_name, current_type, owner_object, selection_result, is_non_null, next_selections, false, ast_node, arguments, field)
|
|
749
786
|
set_result(selection_result, result_name, response_list, true, is_non_null)
|
|
750
|
-
idx = nil
|
|
787
|
+
idx = nil #: Integer?
|
|
751
788
|
list_value = begin
|
|
752
789
|
begin
|
|
753
790
|
value.each do |inner_value|
|
|
@@ -798,6 +835,8 @@ module GraphQL
|
|
|
798
835
|
|
|
799
836
|
def resolve_list_item(inner_value, inner_type, inner_type_non_null, ast_node, field, owner_object, arguments, this_idx, response_list, owner_type, was_scoped, runtime_state) # rubocop:disable Metrics/ParameterLists
|
|
800
837
|
runtime_state ||= get_current_runtime_state
|
|
838
|
+
runtime_state.current_field = field
|
|
839
|
+
runtime_state.current_arguments = arguments
|
|
801
840
|
runtime_state.current_result_name = this_idx
|
|
802
841
|
runtime_state.current_result = response_list
|
|
803
842
|
call_method_on_directives(:resolve_each, owner_object, ast_node.directives) do
|
|
@@ -849,7 +888,7 @@ module GraphQL
|
|
|
849
888
|
end
|
|
850
889
|
end
|
|
851
890
|
|
|
852
|
-
# Check
|
|
891
|
+
# Check [Schema::Directive.include?](rdoc-ref:Schema::Directive.include?) for each directive that's present
|
|
853
892
|
def directives_include?(node, graphql_object, parent_type, selection_result, extra_path_part)
|
|
854
893
|
node.directives.each do |dir_node|
|
|
855
894
|
dir_defn = @schema_directives.fetch(dir_node.name)
|
|
@@ -898,11 +937,19 @@ module GraphQL
|
|
|
898
937
|
end
|
|
899
938
|
end
|
|
900
939
|
|
|
901
|
-
#
|
|
902
|
-
#
|
|
903
|
-
#
|
|
904
|
-
#
|
|
905
|
-
#
|
|
940
|
+
# **Parameters**
|
|
941
|
+
#
|
|
942
|
+
# - `obj` (`Object`) — Some user-returned value that may want to be batched
|
|
943
|
+
# - `field` (`GraphQL::Schema::Field`)
|
|
944
|
+
# - `eager` (`Boolean`) — Set to `true` for mutation root fields only
|
|
945
|
+
# - `trace` (`Boolean`) — If `false`, don't wrap this with field tracing
|
|
946
|
+
#
|
|
947
|
+
# **Returns**
|
|
948
|
+
#
|
|
949
|
+
# - `GraphQL::Execution::Lazy, Object` — If loading `object` will be deferred, it's a wrapper over it.
|
|
950
|
+
#
|
|
951
|
+
# :call-seq:
|
|
952
|
+
# after_lazy(lazy_obj, GraphQL::Schema::Field field:, owner_object:, arguments:, ast_node:, result:, result_name:, bool eager:, runtime_state:, bool trace:, &block) -> GraphQL::Execution::Lazy | Object
|
|
906
953
|
def after_lazy(lazy_obj, field:, owner_object:, arguments:, ast_node:, result:, result_name:, eager: false, runtime_state:, trace: true, &block)
|
|
907
954
|
if lazy?(lazy_obj)
|
|
908
955
|
was_authorized_by_scope_items = runtime_state.was_authorized_by_scope_items
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require "fiber"
|
|
3
4
|
require "graphql/execution/interpreter/argument_value"
|
|
4
5
|
require "graphql/execution/interpreter/arguments"
|
|
@@ -13,15 +14,24 @@ module GraphQL
|
|
|
13
14
|
class Interpreter
|
|
14
15
|
class << self
|
|
15
16
|
# Used internally to signal that the query shouldn't be executed
|
|
16
|
-
#
|
|
17
|
+
# :nodoc:
|
|
17
18
|
NO_OPERATION = GraphQL::EmptyObjects::EMPTY_HASH
|
|
18
19
|
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
20
|
+
# **Parameters**
|
|
21
|
+
#
|
|
22
|
+
# - `schema` (`GraphQL::Schema`)
|
|
23
|
+
# - `queries` (`Array<GraphQL::Query, Hash>`)
|
|
24
|
+
# - `context` (`Hash`)
|
|
25
|
+
# - `max_complexity` (`Integer, nil`)
|
|
26
|
+
#
|
|
27
|
+
# **Returns**
|
|
28
|
+
#
|
|
29
|
+
# - `Array<GraphQL::Query::Result>` — One result per query
|
|
30
|
+
#
|
|
31
|
+
# :call-seq:
|
|
32
|
+
# run_all(GraphQL::Schema schema, query_options, Hash context:, Integer | nil max_complexity:) -> Array[GraphQL::Query::Result]
|
|
24
33
|
def run_all(schema, query_options, context: {}, max_complexity: schema.max_complexity)
|
|
34
|
+
previous_multiplex = Fiber[:__graphql_current_multiplex]
|
|
25
35
|
queries = query_options.map do |opts|
|
|
26
36
|
query = case opts
|
|
27
37
|
when Hash
|
|
@@ -131,7 +141,6 @@ module GraphQL
|
|
|
131
141
|
queries.map { |q| q.result_values ||= {} }
|
|
132
142
|
raise
|
|
133
143
|
ensure
|
|
134
|
-
Fiber[:__graphql_current_multiplex] = nil
|
|
135
144
|
queries.map { |query|
|
|
136
145
|
runtime = query.context.namespace(:interpreter_runtime)[:runtime]
|
|
137
146
|
if runtime
|
|
@@ -140,6 +149,8 @@ module GraphQL
|
|
|
140
149
|
}
|
|
141
150
|
end
|
|
142
151
|
end
|
|
152
|
+
ensure
|
|
153
|
+
Fiber[:__graphql_current_multiplex] = previous_multiplex
|
|
143
154
|
end
|
|
144
155
|
end
|
|
145
156
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require 'thread'
|
|
3
4
|
begin
|
|
4
5
|
require 'concurrent'
|
|
@@ -9,13 +10,12 @@ end
|
|
|
9
10
|
module GraphQL
|
|
10
11
|
module Execution
|
|
11
12
|
class Lazy
|
|
12
|
-
#
|
|
13
|
+
# [GraphQL::Schema](rdoc-ref:GraphQL::Schema) uses this to match returned values to lazy resolution methods.
|
|
13
14
|
# Methods may be registered for classes, they apply to its subclasses also.
|
|
14
15
|
# The result of this lookup is cached for future resolutions.
|
|
15
16
|
# Instances of this class are thread-safe.
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
class LazyMethodMap
|
|
17
|
+
# See the schema's `lazy?` configuration to understand which values use this map.
|
|
18
|
+
class LazyMethodMap # :nodoc:
|
|
19
19
|
def initialize(use_concurrent: defined?(Concurrent::Map))
|
|
20
20
|
@storage = use_concurrent ? Concurrent::Map.new : ConcurrentishMap.new
|
|
21
21
|
end
|
|
@@ -24,14 +24,27 @@ module GraphQL
|
|
|
24
24
|
@storage = other.storage.dup
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
#
|
|
28
|
-
#
|
|
27
|
+
# **Parameters**
|
|
28
|
+
#
|
|
29
|
+
# - `lazy_class` (`Class`) — A class which represents a lazy value (subclasses may also be used)
|
|
30
|
+
# - `lazy_value_method` (`Symbol`) — The method to call on this class to get its value
|
|
31
|
+
#
|
|
32
|
+
# :call-seq:
|
|
33
|
+
# set(Class lazy_class, Symbol lazy_value_method)
|
|
29
34
|
def set(lazy_class, lazy_value_method)
|
|
30
35
|
@storage[lazy_class] = lazy_value_method
|
|
31
36
|
end
|
|
32
37
|
|
|
33
|
-
#
|
|
34
|
-
#
|
|
38
|
+
# **Parameters**
|
|
39
|
+
#
|
|
40
|
+
# - `value` (`Object`) — an object which may have a `lazy_value_method` registered for its class or superclasses
|
|
41
|
+
#
|
|
42
|
+
# **Returns**
|
|
43
|
+
#
|
|
44
|
+
# - `Symbol, nil` — The `lazy_value_method` for this object, or nil
|
|
45
|
+
#
|
|
46
|
+
# :call-seq:
|
|
47
|
+
# get(Object value) -> Symbol | nil
|
|
35
48
|
def get(value)
|
|
36
49
|
@storage.compute_if_absent(value.class) { find_superclass_method(value.class) }
|
|
37
50
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require "graphql/execution/lazy/lazy_method_map"
|
|
3
4
|
|
|
4
5
|
module GraphQL
|
|
@@ -10,20 +11,30 @@ module GraphQL
|
|
|
10
11
|
# This is an itty-bitty promise-like object, with key differences:
|
|
11
12
|
# - It has only two states, not-resolved and resolved
|
|
12
13
|
# - It has no error-catching functionality
|
|
13
|
-
#
|
|
14
|
-
class Lazy
|
|
14
|
+
class Lazy # :nodoc:
|
|
15
15
|
attr_reader :field
|
|
16
16
|
|
|
17
|
-
# Create a
|
|
18
|
-
#
|
|
19
|
-
#
|
|
17
|
+
# Create a [Lazy](rdoc-ref:Lazy) which will get its inner value by calling the block
|
|
18
|
+
#
|
|
19
|
+
# **Parameters**
|
|
20
|
+
#
|
|
21
|
+
# - `field` (`GraphQL::Schema::Field`)
|
|
22
|
+
# - `get_value_func` (`Proc`) — a block to get the inner value (later)
|
|
23
|
+
#
|
|
24
|
+
# :call-seq:
|
|
25
|
+
# initialize(GraphQL::Schema::Field field:, Proc &get_value_func)
|
|
20
26
|
def initialize(field: nil, &get_value_func)
|
|
21
27
|
@get_value_func = get_value_func
|
|
22
28
|
@resolved = false
|
|
23
29
|
@field = field
|
|
24
30
|
end
|
|
25
31
|
|
|
26
|
-
#
|
|
32
|
+
# **Returns**
|
|
33
|
+
#
|
|
34
|
+
# - `Object` — The wrapped value, calling the lazy block if necessary
|
|
35
|
+
#
|
|
36
|
+
# :call-seq:
|
|
37
|
+
# value() -> Object
|
|
27
38
|
def value
|
|
28
39
|
if !@resolved
|
|
29
40
|
@resolved = true
|
|
@@ -45,15 +56,28 @@ module GraphQL
|
|
|
45
56
|
end
|
|
46
57
|
end
|
|
47
58
|
|
|
48
|
-
#
|
|
59
|
+
# **Returns**
|
|
60
|
+
#
|
|
61
|
+
# - `Lazy` — A [Lazy](rdoc-ref:Lazy) whose value depends on another [Lazy](rdoc-ref:Lazy), plus any transformations in `block`
|
|
62
|
+
#
|
|
63
|
+
# :call-seq:
|
|
64
|
+
# then() -> Lazy
|
|
49
65
|
def then
|
|
50
66
|
self.class.new {
|
|
51
67
|
yield(value)
|
|
52
68
|
}
|
|
53
69
|
end
|
|
54
70
|
|
|
55
|
-
#
|
|
56
|
-
#
|
|
71
|
+
# **Parameters**
|
|
72
|
+
#
|
|
73
|
+
# - `lazies` (`Array<Object>`) — Maybe-lazy objects
|
|
74
|
+
#
|
|
75
|
+
# **Returns**
|
|
76
|
+
#
|
|
77
|
+
# - `Lazy` — A lazy which will sync all of `lazies`
|
|
78
|
+
#
|
|
79
|
+
# :call-seq:
|
|
80
|
+
# all(Array[Object] lazies) -> Lazy
|
|
57
81
|
def self.all(lazies)
|
|
58
82
|
self.new {
|
|
59
83
|
lazies.map { |l| l.is_a?(Lazy) ? l.value : l }
|
|
@@ -61,7 +85,7 @@ module GraphQL
|
|
|
61
85
|
end
|
|
62
86
|
|
|
63
87
|
# This can be used for fields which _had no_ lazy results
|
|
64
|
-
#
|
|
88
|
+
# :nodoc:
|
|
65
89
|
NullResult = Lazy.new(){}
|
|
66
90
|
NullResult.value
|
|
67
91
|
end
|