graphql 2.6.11 → 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 +10 -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 +93 -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 +40 -13
- 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 +72 -25
- 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 +24 -17
- 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 +123 -22
- 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 +9 -2
- 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 +65 -20
- 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 +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 +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 +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 +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
|
module GraphQL
|
|
3
4
|
class Query
|
|
4
5
|
class Context
|
|
@@ -13,7 +14,7 @@ module GraphQL
|
|
|
13
14
|
if @scoped_contexts.nil?
|
|
14
15
|
GraphQL::EmptyObjects::EMPTY_HASH
|
|
15
16
|
else
|
|
16
|
-
merged_ctx = {}
|
|
17
|
+
merged_ctx = {} #: untyped
|
|
17
18
|
each_present_path_ctx do |path_ctx|
|
|
18
19
|
merged_ctx = path_ctx.merge(merged_ctx)
|
|
19
20
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Query
|
|
@@ -31,18 +32,30 @@ module GraphQL
|
|
|
31
32
|
extend Forwardable
|
|
32
33
|
include Schema::Member::HasDataloader
|
|
33
34
|
|
|
34
|
-
#
|
|
35
|
+
# **Returns**
|
|
36
|
+
#
|
|
37
|
+
# - `Array<GraphQL::ExecutionError>` — errors returned during execution
|
|
35
38
|
attr_reader :errors
|
|
36
39
|
|
|
37
|
-
#
|
|
40
|
+
# **Returns**
|
|
41
|
+
#
|
|
42
|
+
# - `GraphQL::Query` — The query whose context this is
|
|
38
43
|
attr_reader :query
|
|
39
44
|
|
|
40
|
-
#
|
|
45
|
+
# **Returns**
|
|
46
|
+
#
|
|
47
|
+
# - `GraphQL::Schema`
|
|
41
48
|
attr_reader :schema
|
|
42
49
|
|
|
43
50
|
# Make a new context which delegates key lookup to `values`
|
|
44
|
-
#
|
|
45
|
-
#
|
|
51
|
+
#
|
|
52
|
+
# **Parameters**
|
|
53
|
+
#
|
|
54
|
+
# - `query` (`GraphQL::Query`) — the query who owns this context
|
|
55
|
+
# - `values` (`Hash`) — A hash of arbitrary values which will be accessible at query-time
|
|
56
|
+
#
|
|
57
|
+
# :call-seq:
|
|
58
|
+
# initialize(GraphQL::Query query:, schema:, Hash values:)
|
|
46
59
|
def initialize(query:, schema: query.schema, values:)
|
|
47
60
|
@query = query
|
|
48
61
|
@schema = schema
|
|
@@ -55,7 +68,13 @@ module GraphQL
|
|
|
55
68
|
end
|
|
56
69
|
|
|
57
70
|
# Modify this hash to return extensions to client.
|
|
58
|
-
#
|
|
71
|
+
#
|
|
72
|
+
# **Returns**
|
|
73
|
+
#
|
|
74
|
+
# - `Hash` — A hash that will be added verbatim to the result hash, as `"extensions" => { ... }`
|
|
75
|
+
#
|
|
76
|
+
# :call-seq:
|
|
77
|
+
# response_extensions() -> Hash
|
|
59
78
|
def response_extensions
|
|
60
79
|
namespace(:__query_result_extensions__)
|
|
61
80
|
end
|
|
@@ -64,14 +83,11 @@ module GraphQL
|
|
|
64
83
|
@dataloader ||= self[:dataloader] || (query.multiplex ? query.multiplex.dataloader : schema.dataloader_class.new)
|
|
65
84
|
end
|
|
66
85
|
|
|
67
|
-
#
|
|
68
|
-
attr_writer :interpreter
|
|
86
|
+
attr_writer :interpreter # :nodoc:
|
|
69
87
|
|
|
70
|
-
#
|
|
71
|
-
attr_writer :value
|
|
88
|
+
attr_writer :value # :nodoc:
|
|
72
89
|
|
|
73
|
-
#
|
|
74
|
-
attr_reader :scoped_context
|
|
90
|
+
attr_reader :scoped_context # :nodoc:
|
|
75
91
|
|
|
76
92
|
def []=(key, value)
|
|
77
93
|
@provided_values[key] = value
|
|
@@ -86,10 +102,9 @@ module GraphQL
|
|
|
86
102
|
attr_writer :types
|
|
87
103
|
|
|
88
104
|
RUNTIME_METADATA_KEYS = Set.new([:current_object, :current_arguments, :current_field, :current_path]).freeze
|
|
89
|
-
#
|
|
90
|
-
# Reassign `key` to the hash passed to {Schema#execute} as `context:`
|
|
105
|
+
# **Method:** `[]=(key, value)` — Reassign `key` to the hash passed to [Schema#execute](rdoc-ref:Schema#execute) as `context:`
|
|
91
106
|
|
|
92
|
-
# Lookup `key` from the hash passed to
|
|
107
|
+
# Lookup `key` from the hash passed to [Schema.execute](rdoc-ref:GraphQL::Schema.execute) as `context:`
|
|
93
108
|
def [](key)
|
|
94
109
|
if @scoped_context.key?(key)
|
|
95
110
|
@scoped_context[key]
|
|
@@ -116,8 +131,17 @@ module GraphQL
|
|
|
116
131
|
end
|
|
117
132
|
|
|
118
133
|
# Add error at query-level.
|
|
119
|
-
#
|
|
120
|
-
#
|
|
134
|
+
#
|
|
135
|
+
# **Parameters**
|
|
136
|
+
#
|
|
137
|
+
# - `error` (`GraphQL::ExecutionError`) — an execution error
|
|
138
|
+
#
|
|
139
|
+
# **Returns**
|
|
140
|
+
#
|
|
141
|
+
# - `void`
|
|
142
|
+
#
|
|
143
|
+
# :call-seq:
|
|
144
|
+
# add_error(GraphQL::ExecutionError error) -> void
|
|
121
145
|
def add_error(error)
|
|
122
146
|
if !error.is_a?(GraphQL::RuntimeError)
|
|
123
147
|
raise TypeError, "expected error to be a GraphQL::RuntimeError, but was #{error.class}"
|
|
@@ -126,16 +150,34 @@ module GraphQL
|
|
|
126
150
|
nil
|
|
127
151
|
end
|
|
128
152
|
|
|
129
|
-
#
|
|
130
|
-
#
|
|
153
|
+
# **Parameters**
|
|
154
|
+
#
|
|
155
|
+
# - `value` (`Object`) — Any object to be inserted directly into the final response
|
|
156
|
+
#
|
|
157
|
+
# **Returns**
|
|
158
|
+
#
|
|
159
|
+
# - `GraphQL::Execution::Interpreter::RawValue` — Return this from the field
|
|
160
|
+
#
|
|
161
|
+
# :call-seq:
|
|
162
|
+
# raw_value(Object value) -> GraphQL::Execution::Interpreter::RawValue
|
|
131
163
|
def raw_value(value)
|
|
132
164
|
GraphQL::Execution::Interpreter::RawValue.new(value)
|
|
133
165
|
end
|
|
134
166
|
|
|
135
|
-
#
|
|
136
|
-
# puts ctx.backtrace
|
|
167
|
+
# **Examples**
|
|
137
168
|
#
|
|
138
|
-
#
|
|
169
|
+
# **Example: Print the GraphQL backtrace during field resolution**
|
|
170
|
+
#
|
|
171
|
+
# ```ruby
|
|
172
|
+
# puts ctx.backtrace
|
|
173
|
+
# ```
|
|
174
|
+
#
|
|
175
|
+
# **Returns**
|
|
176
|
+
#
|
|
177
|
+
# - `GraphQL::Backtrace` — The backtrace for this point in query execution
|
|
178
|
+
#
|
|
179
|
+
# :call-seq:
|
|
180
|
+
# backtrace() -> GraphQL::Backtrace
|
|
139
181
|
def backtrace
|
|
140
182
|
GraphQL::Backtrace.new(self)
|
|
141
183
|
end
|
|
@@ -217,17 +259,30 @@ module GraphQL
|
|
|
217
259
|
@scoped_context.key?(key) || @provided_values.key?(key)
|
|
218
260
|
end
|
|
219
261
|
|
|
220
|
-
#
|
|
262
|
+
# **Returns**
|
|
263
|
+
#
|
|
264
|
+
# - `GraphQL::Schema::Warden`
|
|
265
|
+
#
|
|
266
|
+
# :call-seq:
|
|
267
|
+
# warden() -> GraphQL::Schema::Warden
|
|
221
268
|
def warden
|
|
222
269
|
@warden ||= (@query && @query.warden)
|
|
223
270
|
end
|
|
224
271
|
|
|
225
|
-
#
|
|
226
|
-
attr_writer :warden
|
|
272
|
+
attr_writer :warden # :nodoc:
|
|
227
273
|
|
|
228
274
|
# Get an isolated hash for `ns`. Doesn't affect user-provided storage.
|
|
229
|
-
#
|
|
230
|
-
#
|
|
275
|
+
#
|
|
276
|
+
# **Parameters**
|
|
277
|
+
#
|
|
278
|
+
# - `ns` (`Object`) — a usage-specific namespace identifier
|
|
279
|
+
#
|
|
280
|
+
# **Returns**
|
|
281
|
+
#
|
|
282
|
+
# - `Hash` — namespaced storage
|
|
283
|
+
#
|
|
284
|
+
# :call-seq:
|
|
285
|
+
# namespace(Object ns) -> Hash
|
|
231
286
|
def namespace(ns)
|
|
232
287
|
if ns == :interpreter
|
|
233
288
|
self
|
|
@@ -236,7 +291,12 @@ module GraphQL
|
|
|
236
291
|
end
|
|
237
292
|
end
|
|
238
293
|
|
|
239
|
-
#
|
|
294
|
+
# **Returns**
|
|
295
|
+
#
|
|
296
|
+
# - `Boolean` — true if this namespace was accessed before
|
|
297
|
+
#
|
|
298
|
+
# :call-seq:
|
|
299
|
+
# namespace?(ns) -> bool
|
|
240
300
|
def namespace?(ns)
|
|
241
301
|
@storage.key?(ns)
|
|
242
302
|
end
|
|
@@ -261,13 +321,24 @@ module GraphQL
|
|
|
261
321
|
# Use this when you need to do a scoped set _inside_ a lazy-loaded (or batch-loaded)
|
|
262
322
|
# block of code.
|
|
263
323
|
#
|
|
264
|
-
#
|
|
265
|
-
#
|
|
266
|
-
#
|
|
267
|
-
#
|
|
268
|
-
#
|
|
269
|
-
#
|
|
270
|
-
#
|
|
324
|
+
# **Examples**
|
|
325
|
+
#
|
|
326
|
+
# **Example: using scoped context inside a promise**
|
|
327
|
+
#
|
|
328
|
+
# ```ruby
|
|
329
|
+
# scoped_ctx = context.scoped
|
|
330
|
+
# SomeBatchLoader.load(...).then do |thing|
|
|
331
|
+
# # use a scoped_ctx which was created _before_ dataloading:
|
|
332
|
+
# scoped_ctx.set!(:thing, thing)
|
|
333
|
+
# end
|
|
334
|
+
# ```
|
|
335
|
+
#
|
|
336
|
+
# **Returns**
|
|
337
|
+
#
|
|
338
|
+
# - `Context::Scoped`
|
|
339
|
+
#
|
|
340
|
+
# :call-seq:
|
|
341
|
+
# scoped() -> Context::Scoped
|
|
271
342
|
def scoped
|
|
272
343
|
Scoped.new(@scoped_context, current_path)
|
|
273
344
|
end
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
require 'digest/sha2'
|
|
4
5
|
|
|
5
6
|
module GraphQL
|
|
6
7
|
class Query
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
|
|
10
|
-
# @see Query#fingerprint
|
|
11
|
-
module Fingerprint
|
|
8
|
+
# The resulting hashes are exposed by `Query#operation_fingerprint`,
|
|
9
|
+
# `Query#variables_fingerprint`, and `Query#fingerprint`.
|
|
10
|
+
module Fingerprint # :nodoc:
|
|
12
11
|
# Make an obfuscated hash of the given string (either a query string or variables JSON)
|
|
13
|
-
#
|
|
14
|
-
#
|
|
12
|
+
#
|
|
13
|
+
# **Parameters**
|
|
14
|
+
#
|
|
15
|
+
# - `string` (`String`)
|
|
16
|
+
#
|
|
17
|
+
# **Returns**
|
|
18
|
+
#
|
|
19
|
+
# - `String` — A normalized, opaque hash
|
|
20
|
+
#
|
|
21
|
+
# :call-seq:
|
|
22
|
+
# generate(input_str) -> String
|
|
15
23
|
def self.generate(input_str)
|
|
16
24
|
# Implemented to be:
|
|
17
25
|
# - Short (and uniform) length
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Query
|
|
4
|
-
# This class is _like_ a
|
|
5
|
+
# This class is _like_ a [GraphQL::Query](rdoc-ref:GraphQL::Query), except it can run on an arbitrary path within a query string.
|
|
5
6
|
#
|
|
6
|
-
# It depends on a "parent"
|
|
7
|
+
# It depends on a "parent" [Query](rdoc-ref:Query).
|
|
7
8
|
#
|
|
8
9
|
# During execution, it calls query-related tracing hooks but passes itself as `query:`.
|
|
9
10
|
#
|
|
10
|
-
# The
|
|
11
|
+
# The [Partial](rdoc-ref:Partial) will use your [Schema.resolve_type](rdoc-ref:Schema.resolve_type) hook to find the right GraphQL type to use for
|
|
11
12
|
# `object` in some cases.
|
|
12
13
|
#
|
|
13
|
-
#
|
|
14
|
+
# Run via [Query#run_partials](rdoc-ref:Query#run_partials).
|
|
14
15
|
class Partial
|
|
15
16
|
include Query::Runnable
|
|
16
17
|
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
18
|
+
# **Parameters**
|
|
19
|
+
#
|
|
20
|
+
# - `path` (`Array<String, Integer>`) — A path in `query.query_string` to start executing from
|
|
21
|
+
# - `object` (`Object`) — A starting object for execution
|
|
22
|
+
# - `query` (`GraphQL::Query`) — A full query instance that this partial is based on. Caches are shared.
|
|
23
|
+
# - `context` (`Hash`) — Extra context values to merge into `query.context`, if provided
|
|
24
|
+
# - `fragment_node` (`GraphQL::Language::Nodes::InlineFragment, GraphQL::Language::Nodes::FragmentDefinition`)
|
|
25
|
+
#
|
|
26
|
+
# :call-seq:
|
|
27
|
+
# initialize(Array[String | Integer] path:, Object object:, GraphQL::Query query:, Hash context:, GraphQL::Language::Nodes::InlineFragment | GraphQL::Language::Nodes::FragmentDefinition fragment_node:, type:)
|
|
22
28
|
def initialize(path: nil, object:, query:, context: nil, fragment_node: nil, type: nil)
|
|
23
29
|
@path = path
|
|
24
30
|
@object = object
|
|
@@ -65,7 +71,12 @@ module GraphQL
|
|
|
65
71
|
@query.path
|
|
66
72
|
end
|
|
67
73
|
|
|
68
|
-
#
|
|
74
|
+
# **Returns**
|
|
75
|
+
#
|
|
76
|
+
# - `GraphQL::Query::Partial`
|
|
77
|
+
#
|
|
78
|
+
# :call-seq:
|
|
79
|
+
# partial() -> GraphQL::Query::Partial
|
|
69
80
|
def partial
|
|
70
81
|
@query
|
|
71
82
|
end
|
|
@@ -138,9 +149,9 @@ module GraphQL
|
|
|
138
149
|
private
|
|
139
150
|
|
|
140
151
|
def set_type_info_from_path
|
|
141
|
-
selections = [@query.selected_operation]
|
|
152
|
+
selections = [@query.selected_operation] #: Array[GraphQL::Language::Nodes::OperationDefinition | GraphQL::Language::Nodes::Field]
|
|
142
153
|
type = @query.root_type
|
|
143
|
-
field_defn = nil
|
|
154
|
+
field_defn = nil #: GraphQL::Schema::Field?
|
|
144
155
|
|
|
145
156
|
@path.each do |name_in_doc|
|
|
146
157
|
if name_in_doc.is_a?(Integer)
|
|
@@ -152,9 +163,9 @@ module GraphQL
|
|
|
152
163
|
end
|
|
153
164
|
end
|
|
154
165
|
|
|
155
|
-
next_selections = []
|
|
166
|
+
next_selections = [] #: Array[GraphQL::Language::Nodes::Field]
|
|
156
167
|
selections.each do |selection|
|
|
157
|
-
selections_to_check = []
|
|
168
|
+
selections_to_check = [] #: Array[GraphQL::Language::Nodes::Field | GraphQL::Language::Nodes::InlineFragment | GraphQL::Language::Nodes::FragmentSpread]
|
|
158
169
|
selections_to_check.concat(selection.selections)
|
|
159
170
|
while (sel = selections_to_check.shift)
|
|
160
171
|
case sel
|
|
@@ -169,6 +180,7 @@ module GraphQL
|
|
|
169
180
|
end
|
|
170
181
|
else
|
|
171
182
|
raise "Unexpected selection in partial path: #{sel.class}, #{sel.inspect}"
|
|
183
|
+
sel #: absurd
|
|
172
184
|
end
|
|
173
185
|
end
|
|
174
186
|
end
|
|
@@ -176,7 +188,8 @@ module GraphQL
|
|
|
176
188
|
if next_selections.empty?
|
|
177
189
|
raise ArgumentError, "Path `#{@path.inspect}` is not present in this query. `#{name_in_doc.inspect}` was not found. Try a different path or rewrite the query to include it."
|
|
178
190
|
end
|
|
179
|
-
|
|
191
|
+
first_selection = next_selections.first #: as !nil
|
|
192
|
+
field_name = first_selection.name
|
|
180
193
|
field_defn = @schema.get_field(type, field_name, @query.context) || raise("Invariant: no field called #{field_name} on #{type.graphql_name}")
|
|
181
194
|
type = field_defn.type
|
|
182
195
|
if type.non_null?
|
data/lib/graphql/query/result.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Query
|
|
5
|
-
# A result from
|
|
6
|
+
# A result from [Schema.execute](rdoc-ref:GraphQL::Schema.execute).
|
|
6
7
|
# It provides the requested data and
|
|
7
|
-
# access to the
|
|
8
|
+
# access to the [Query](rdoc-ref:GraphQL::Query) and [Query::Context](rdoc-ref:GraphQL::Query::Context).
|
|
8
9
|
class Result
|
|
9
10
|
extend Forwardable
|
|
10
11
|
|
|
@@ -13,10 +14,14 @@ module GraphQL
|
|
|
13
14
|
@to_h = values
|
|
14
15
|
end
|
|
15
16
|
|
|
16
|
-
#
|
|
17
|
+
# **Returns**
|
|
18
|
+
#
|
|
19
|
+
# - `GraphQL::Query` — The query that was executed
|
|
17
20
|
attr_reader :query
|
|
18
21
|
|
|
19
|
-
#
|
|
22
|
+
# **Returns**
|
|
23
|
+
#
|
|
24
|
+
# - `Hash` — The resulting hash of "data" and/or "errors"
|
|
20
25
|
attr_reader :to_h
|
|
21
26
|
|
|
22
27
|
def_delegators :@query, :context, :mutation?, :query?, :subscription?
|
|
@@ -47,7 +52,12 @@ module GraphQL
|
|
|
47
52
|
#
|
|
48
53
|
# (The query is ignored for comparing result equality.)
|
|
49
54
|
#
|
|
50
|
-
#
|
|
55
|
+
# **Returns**
|
|
56
|
+
#
|
|
57
|
+
# - `Boolean`
|
|
58
|
+
#
|
|
59
|
+
# :call-seq:
|
|
60
|
+
# ==(other) -> bool
|
|
51
61
|
def ==(other)
|
|
52
62
|
case other
|
|
53
63
|
when Hash
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Query
|
|
4
5
|
# Contain the validation pipeline and expose the results.
|
|
5
6
|
#
|
|
6
|
-
# 0. Checks in
|
|
7
|
+
# 0. Checks in the [GraphQL::Query](rdoc-ref:GraphQL::Query) constructor:
|
|
7
8
|
# - Rescue a ParseError, halt if there is one
|
|
8
9
|
# - Check for selected operation, halt if not found
|
|
9
10
|
# 1. Validate the AST, halt if errors
|
|
10
11
|
# 2. Validate the variables, halt if errors
|
|
11
12
|
# 3. Run query analyzers, halt if errors
|
|
12
13
|
#
|
|
13
|
-
#
|
|
14
|
+
# [valid?](rdoc-ref:#valid?) is false if any of the above checks halted the pipeline.
|
|
14
15
|
#
|
|
15
|
-
#
|
|
16
|
-
class ValidationPipeline
|
|
16
|
+
class ValidationPipeline # :nodoc:
|
|
17
17
|
attr_reader :max_depth, :max_complexity, :validate_timeout_remaining
|
|
18
18
|
|
|
19
19
|
def initialize(query:, parse_error:, operation_name_error:, max_depth:, max_complexity:)
|
|
@@ -28,13 +28,23 @@ module GraphQL
|
|
|
28
28
|
@has_validated = false
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
#
|
|
31
|
+
# **Returns**
|
|
32
|
+
#
|
|
33
|
+
# - `Boolean` — does this query have errors that should prevent it from running?
|
|
34
|
+
#
|
|
35
|
+
# :call-seq:
|
|
36
|
+
# valid?() -> bool
|
|
32
37
|
def valid?
|
|
33
38
|
ensure_has_validated
|
|
34
39
|
@valid
|
|
35
40
|
end
|
|
36
41
|
|
|
37
|
-
#
|
|
42
|
+
# **Returns**
|
|
43
|
+
#
|
|
44
|
+
# - `Array<GraphQL::StaticValidation::Error, GraphQL::Query::VariableValidationError>` — Static validation errors for the query string
|
|
45
|
+
#
|
|
46
|
+
# :call-seq:
|
|
47
|
+
# validation_errors() -> Array[GraphQL::StaticValidation::Error | GraphQL::Query::VariableValidationError]
|
|
38
48
|
def validation_errors
|
|
39
49
|
ensure_has_validated
|
|
40
50
|
@validation_errors
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Query
|
|
4
5
|
# Read-only access to query variables, applying default values if needed.
|
|
5
6
|
class Variables
|
|
6
7
|
extend Forwardable
|
|
7
8
|
|
|
8
|
-
#
|
|
9
|
+
# **Returns**
|
|
10
|
+
#
|
|
11
|
+
# - `Array<GraphQL::Query::VariableValidationError>` — Any errors encountered when parsing the provided variables and literal values
|
|
9
12
|
attr_reader :errors
|
|
10
13
|
|
|
11
14
|
attr_reader :context
|
|
@@ -35,7 +38,11 @@ module GraphQL
|
|
|
35
38
|
value_was_provided = @provided_variables.key?(variable_name)
|
|
36
39
|
max_errors = schema.validate_max_errors - @errors.count if schema.validate_max_errors
|
|
37
40
|
begin
|
|
38
|
-
validation_result =
|
|
41
|
+
validation_result = if value_was_provided || default_value.nil?
|
|
42
|
+
variable_type.validate_input(provided_value, ctx, max_errors: max_errors)
|
|
43
|
+
else
|
|
44
|
+
GraphQL::Query::InputValidationResult::VALID
|
|
45
|
+
end
|
|
39
46
|
if validation_result.valid?
|
|
40
47
|
if value_was_provided
|
|
41
48
|
# Add the variable if a value was provided
|