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,23 +1,31 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Schema
|
|
4
|
-
# You can use the result of
|
|
5
|
+
# You can use the result of [GraphQL::Introspection::INTROSPECTION_QUERY](rdoc-ref:GraphQL::Introspection::INTROSPECTION_QUERY)
|
|
5
6
|
# to make a schema. This schema is missing some important details like
|
|
6
7
|
# `resolve` functions, but it does include the full type system,
|
|
7
8
|
# so you can use it to validate queries.
|
|
8
9
|
#
|
|
9
|
-
#
|
|
10
|
+
# See [GraphQL::Schema.from_introspection](rdoc-ref:GraphQL::Schema.from_introspection) for a public API
|
|
10
11
|
module Loader
|
|
11
|
-
extend self
|
|
12
|
-
|
|
13
12
|
# Create schema with the result of an introspection query.
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
|
|
13
|
+
#
|
|
14
|
+
# **Parameters**
|
|
15
|
+
#
|
|
16
|
+
# - `introspection_result` (`Hash`) — A response from [GraphQL::Introspection::INTROSPECTION_QUERY](rdoc-ref:GraphQL::Introspection::INTROSPECTION_QUERY)
|
|
17
|
+
#
|
|
18
|
+
# **Returns**
|
|
19
|
+
#
|
|
20
|
+
# - `Class` — the schema described by `input`
|
|
21
|
+
#
|
|
22
|
+
# :call-seq:
|
|
23
|
+
# load(Hash introspection_result) -> Class
|
|
24
|
+
def self.load(introspection_result)
|
|
17
25
|
schema = introspection_result.fetch("data").fetch("__schema")
|
|
18
26
|
|
|
19
27
|
types = {}
|
|
20
|
-
type_resolver = ->(type) {
|
|
28
|
+
type_resolver = ->(type) { resolve_type_reference(types, type) }
|
|
21
29
|
|
|
22
30
|
schema.fetch("types").each do |type|
|
|
23
31
|
next if type.fetch("name").start_with?("__")
|
|
@@ -56,7 +64,7 @@ module GraphQL
|
|
|
56
64
|
class << self
|
|
57
65
|
private
|
|
58
66
|
|
|
59
|
-
def
|
|
67
|
+
def resolve_type_reference(types, type)
|
|
60
68
|
case kind = type.fetch("kind")
|
|
61
69
|
when "ENUM", "INTERFACE", "INPUT_OBJECT", "OBJECT", "SCALAR", "UNION"
|
|
62
70
|
type_name = type.fetch("name")
|
|
@@ -67,9 +75,9 @@ module GraphQL
|
|
|
67
75
|
type
|
|
68
76
|
end
|
|
69
77
|
when "LIST"
|
|
70
|
-
Schema::List.new(
|
|
78
|
+
Schema::List.new(resolve_type_reference(types, type.fetch("ofType")))
|
|
71
79
|
when "NON_NULL"
|
|
72
|
-
Schema::NonNull.new(
|
|
80
|
+
Schema::NonNull.new(resolve_type_reference(types, type.fetch("ofType")))
|
|
73
81
|
else
|
|
74
82
|
fail GraphQL::RequiredImplementationMissingError, "#{kind} not implemented"
|
|
75
83
|
end
|
|
@@ -113,6 +121,7 @@ module GraphQL
|
|
|
113
121
|
end
|
|
114
122
|
when "INTERFACE"
|
|
115
123
|
Module.new do
|
|
124
|
+
#: self as GraphQL::Schema::Member::interface_definition
|
|
116
125
|
include GraphQL::Schema::Interface
|
|
117
126
|
graphql_name(type["name"])
|
|
118
127
|
description(type["description"])
|
|
@@ -213,7 +222,9 @@ module GraphQL
|
|
|
213
222
|
dummy_query_ast = GraphQL.parse(dummy_query_str)
|
|
214
223
|
|
|
215
224
|
# Reach into the AST for the default value:
|
|
216
|
-
|
|
225
|
+
operation = dummy_query_ast.definitions.first #: as GraphQL::Language::Nodes::OperationDefinition
|
|
226
|
+
variable = operation.variables.first #: as !nil
|
|
227
|
+
input_value_ast = variable.default_value
|
|
217
228
|
|
|
218
229
|
kwargs[:default_value] = extract_default_value(default_value_str, input_value_ast)
|
|
219
230
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
require "graphql/schema/find_inherited_value"
|
|
4
5
|
|
|
@@ -6,17 +7,28 @@ module GraphQL
|
|
|
6
7
|
class Schema
|
|
7
8
|
class Member
|
|
8
9
|
# DSL methods shared by lots of things in the GraphQL Schema.
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
# See classes that extend this, eg [GraphQL::Schema::Object](rdoc-ref:GraphQL::Schema::Object)
|
|
11
|
+
#--
|
|
12
|
+
# @requires_ancestor: Kernel
|
|
13
|
+
# @requires_ancestor: Module
|
|
14
|
+
module BaseDSLMethods # :nodoc:
|
|
12
15
|
include GraphQL::Schema::FindInheritedValue
|
|
13
16
|
|
|
14
17
|
# Call this with a new name to override the default name for this schema member; OR
|
|
15
18
|
# call it without an argument to get the name of this schema member
|
|
16
19
|
#
|
|
17
20
|
# The default name is implemented in default_graphql_name
|
|
18
|
-
#
|
|
19
|
-
#
|
|
21
|
+
#
|
|
22
|
+
# **Parameters**
|
|
23
|
+
#
|
|
24
|
+
# - `new_name` (`String`)
|
|
25
|
+
#
|
|
26
|
+
# **Returns**
|
|
27
|
+
#
|
|
28
|
+
# - `String`
|
|
29
|
+
#
|
|
30
|
+
# :call-seq:
|
|
31
|
+
# graphql_name(String new_name) -> String
|
|
20
32
|
def graphql_name(new_name = nil)
|
|
21
33
|
if new_name
|
|
22
34
|
GraphQL::NameValidator.validate!(new_name)
|
|
@@ -28,8 +40,17 @@ module GraphQL
|
|
|
28
40
|
|
|
29
41
|
# Call this method to provide a new description; OR
|
|
30
42
|
# call it without an argument to get the description
|
|
31
|
-
#
|
|
32
|
-
#
|
|
43
|
+
#
|
|
44
|
+
# **Parameters**
|
|
45
|
+
#
|
|
46
|
+
# - `new_description` (`String`)
|
|
47
|
+
#
|
|
48
|
+
# **Returns**
|
|
49
|
+
#
|
|
50
|
+
# - `String`
|
|
51
|
+
#
|
|
52
|
+
# :call-seq:
|
|
53
|
+
# description(String new_description) -> String
|
|
33
54
|
def description(new_description = nil)
|
|
34
55
|
if new_description
|
|
35
56
|
@description = new_description
|
|
@@ -42,8 +63,17 @@ module GraphQL
|
|
|
42
63
|
|
|
43
64
|
# Call this method to provide a new comment; OR
|
|
44
65
|
# call it without an argument to get the comment
|
|
45
|
-
#
|
|
46
|
-
#
|
|
66
|
+
#
|
|
67
|
+
# **Parameters**
|
|
68
|
+
#
|
|
69
|
+
# - `new_comment` (`String`)
|
|
70
|
+
#
|
|
71
|
+
# **Returns**
|
|
72
|
+
#
|
|
73
|
+
# - `String, nil`
|
|
74
|
+
#
|
|
75
|
+
# :call-seq:
|
|
76
|
+
# comment(String new_comment) -> String | nil
|
|
47
77
|
def comment(new_comment = NOT_CONFIGURED)
|
|
48
78
|
if !NOT_CONFIGURED.equal?(new_comment)
|
|
49
79
|
@comment = new_comment
|
|
@@ -56,6 +86,9 @@ module GraphQL
|
|
|
56
86
|
|
|
57
87
|
# This pushes some configurations _down_ the inheritance tree,
|
|
58
88
|
# in order to prevent repetitive lookups at runtime.
|
|
89
|
+
#--
|
|
90
|
+
# @requires_ancestor: Module
|
|
91
|
+
# @requires_ancestor: GraphQL::Schema::Member::BaseDSLMethods
|
|
59
92
|
module ConfigurationExtension
|
|
60
93
|
def inherited(child_class)
|
|
61
94
|
child_class.introspection(introspection)
|
|
@@ -72,7 +105,12 @@ module GraphQL
|
|
|
72
105
|
end
|
|
73
106
|
end
|
|
74
107
|
|
|
75
|
-
#
|
|
108
|
+
# **Returns**
|
|
109
|
+
#
|
|
110
|
+
# - `Boolean` — If true, this object is part of the introspection system
|
|
111
|
+
#
|
|
112
|
+
# :call-seq:
|
|
113
|
+
# introspection(new_introspection) -> bool
|
|
76
114
|
def introspection(new_introspection = nil)
|
|
77
115
|
if !new_introspection.nil?
|
|
78
116
|
@introspection = new_introspection
|
|
@@ -88,7 +126,13 @@ module GraphQL
|
|
|
88
126
|
end
|
|
89
127
|
|
|
90
128
|
# The mutation this type was derived from, if it was derived from a mutation
|
|
91
|
-
#
|
|
129
|
+
#
|
|
130
|
+
# **Returns**
|
|
131
|
+
#
|
|
132
|
+
# - `Class`
|
|
133
|
+
#
|
|
134
|
+
# :call-seq:
|
|
135
|
+
# mutation(mutation_class) -> Class
|
|
92
136
|
def mutation(mutation_class = nil)
|
|
93
137
|
if mutation_class
|
|
94
138
|
@mutation = mutation_class
|
|
@@ -107,7 +151,9 @@ module GraphQL
|
|
|
107
151
|
def default_graphql_name
|
|
108
152
|
@default_graphql_name ||= begin
|
|
109
153
|
raise GraphQL::RequiredImplementationMissingError, 'Anonymous class should declare a `graphql_name`' if name.nil?
|
|
110
|
-
|
|
154
|
+
class_name = name #: as !nil
|
|
155
|
+
short_name = class_name.split("::").last #: as String
|
|
156
|
+
g_name = -short_name
|
|
111
157
|
g_name.end_with?("Type") ? g_name.sub(/Type\Z/, "") : g_name
|
|
112
158
|
end
|
|
113
159
|
end
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Schema
|
|
4
5
|
class Member
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
#--
|
|
7
|
+
# @requires_ancestor: Kernel
|
|
8
|
+
module BuildType # :nodoc:
|
|
7
9
|
LIST_TYPE_ERROR = "Use an array of [T] or [T, null: true] for list types; other arrays are not supported"
|
|
8
10
|
|
|
9
11
|
module_function
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
+
# **Parameters**
|
|
13
|
+
#
|
|
14
|
+
# - `type_expr` (`String, Class, GraphQL::BaseType`)
|
|
15
|
+
#
|
|
16
|
+
# **Returns**
|
|
17
|
+
#
|
|
18
|
+
# - `GraphQL::BaseType`
|
|
19
|
+
#
|
|
20
|
+
# :call-seq:
|
|
21
|
+
# parse_type(String | Class | GraphQL::BaseType type_expr, null:) -> GraphQL::BaseType
|
|
12
22
|
def parse_type(type_expr, null:)
|
|
13
23
|
list_type = false
|
|
14
24
|
|
|
@@ -104,7 +114,8 @@ module GraphQL
|
|
|
104
114
|
to_type_name(something.first)
|
|
105
115
|
when Module
|
|
106
116
|
if something.respond_to?(:graphql_name)
|
|
107
|
-
something
|
|
117
|
+
type_defn = something #: as GraphQL::Schema::Member::type_definition
|
|
118
|
+
type_defn.graphql_name
|
|
108
119
|
else
|
|
109
120
|
to_type_name(something.name)
|
|
110
121
|
end
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
5
6
|
class Member
|
|
6
7
|
# These constants are interpreted as GraphQL types when defining fields or arguments
|
|
7
8
|
#
|
|
8
|
-
# @example
|
|
9
|
-
# field :is_draft, Boolean, null: false
|
|
10
|
-
# field :id, ID, null: false
|
|
11
|
-
# field :score, Int, null: false
|
|
12
9
|
#
|
|
13
|
-
#
|
|
14
|
-
|
|
10
|
+
# **Examples**
|
|
11
|
+
#
|
|
12
|
+
# **Example: field :is_draft, Boolean, null: false**
|
|
13
|
+
#
|
|
14
|
+
# ```ruby
|
|
15
|
+
# field :id, ID, null: false
|
|
16
|
+
# field :score, Int, null: false
|
|
17
|
+
# ```
|
|
18
|
+
module GraphQLTypeNames # :nodoc:
|
|
15
19
|
Boolean = "Boolean"
|
|
16
20
|
ID = "ID"
|
|
17
21
|
Int = "Int"
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Schema
|
|
4
5
|
class Member
|
|
6
|
+
#--
|
|
7
|
+
# @requires_ancestor: Kernel
|
|
5
8
|
module HasArguments
|
|
6
9
|
def self.included(cls)
|
|
7
10
|
cls.extend(ArgumentClassAccessor)
|
|
@@ -14,28 +17,39 @@ module GraphQL
|
|
|
14
17
|
cls.extend(ClassConfigured)
|
|
15
18
|
end
|
|
16
19
|
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
#
|
|
20
|
+
# **Parameters**
|
|
21
|
+
#
|
|
22
|
+
# - `arg_name` (`Symbol`) — The underscore-cased name of this argument, `name:` keyword also accepted
|
|
23
|
+
# - `type_expr` — The GraphQL type of this argument; `type:` keyword also accepted
|
|
24
|
+
# - `desc` (`String`) — Argument description, `description:` keyword also accepted
|
|
25
|
+
# - `definition_block` (`Proc`) — Called with the newly-created [Argument](rdoc-ref:Argument)
|
|
26
|
+
# - `kwargs` (`Hash`) — Keywords for defining an argument. Any keywords not documented here must be handled by your base Argument class.
|
|
27
|
+
#
|
|
28
|
+
# **Options**
|
|
29
|
+
#
|
|
30
|
+
# - `kwargs.:required` (`Boolean, :nullable`) — if true, this argument is non-null; if false, this argument is nullable. If `:nullable`, then the argument must be provided, though it may be `null`.
|
|
31
|
+
# - `kwargs.:description` (`String`) — Positional argument also accepted
|
|
32
|
+
# - `kwargs.:type` (`Class, Array<Class>`) — Input type; positional argument also accepted
|
|
33
|
+
# - `kwargs.:name` (`Symbol`) — positional argument also accepted
|
|
34
|
+
# - `kwargs.:default_value` (`Object`)
|
|
35
|
+
# - `kwargs.:loads` (`Class, Array<Class>`) — A GraphQL type to load for the given ID when one is present
|
|
36
|
+
# - `kwargs.:as` (`Symbol`) — Override the keyword name when passed to a method
|
|
37
|
+
# - `kwargs.:prepare` (`Symbol`) — A method to call to transform this argument's valuebefore sending it to field resolution
|
|
38
|
+
# - `kwargs.:camelize` (`Boolean`) — if true, the name will be camelized when building the schema
|
|
39
|
+
# - `kwargs.:from_resolver` (`Boolean`) — if true, a Resolver class defined this argument
|
|
40
|
+
# - `kwargs.:directives` (`Hash{Class => Hash}`)
|
|
41
|
+
# - `kwargs.:deprecation_reason` (`String`)
|
|
42
|
+
# - `kwargs.:comment` (`String`) — Private, used by GraphQL-Ruby when parsing GraphQL schema files
|
|
43
|
+
# - `kwargs.:ast_node` (`GraphQL::Language::Nodes::InputValueDefinition`) — Private, used by GraphQL-Ruby when parsing schema files
|
|
44
|
+
# - `kwargs.:validates` (`Hash, nil`) — Options for building validators, if any should be applied
|
|
45
|
+
# - `kwargs.:replace_null_with_default` (`Boolean`) — if `true`, incoming values of `null` will be replaced with the configured `default_value`
|
|
46
|
+
#
|
|
47
|
+
# **Returns**
|
|
48
|
+
#
|
|
49
|
+
# - `GraphQL::Schema::Argument` — An instance of [argument_class](rdoc-ref:argument_class) created from these arguments
|
|
50
|
+
#
|
|
51
|
+
# :call-seq:
|
|
52
|
+
# argument(Symbol arg_name, type_expr, String desc, Hash **kwargs, Proc &definition_block) -> GraphQL::Schema::Argument
|
|
39
53
|
def argument(arg_name = nil, type_expr = nil, desc = nil, **kwargs, &definition_block)
|
|
40
54
|
if kwargs[:loads]
|
|
41
55
|
loads_name = arg_name || kwargs[:name]
|
|
@@ -65,8 +79,17 @@ module GraphQL
|
|
|
65
79
|
end
|
|
66
80
|
|
|
67
81
|
# Register this argument with the class.
|
|
68
|
-
#
|
|
69
|
-
#
|
|
82
|
+
#
|
|
83
|
+
# **Parameters**
|
|
84
|
+
#
|
|
85
|
+
# - `arg_defn` (`GraphQL::Schema::Argument`)
|
|
86
|
+
#
|
|
87
|
+
# **Returns**
|
|
88
|
+
#
|
|
89
|
+
# - `GraphQL::Schema::Argument`
|
|
90
|
+
#
|
|
91
|
+
# :call-seq:
|
|
92
|
+
# add_argument(GraphQL::Schema::Argument arg_defn) -> GraphQL::Schema::Argument
|
|
70
93
|
def add_argument(arg_defn)
|
|
71
94
|
@own_arguments ||= {}
|
|
72
95
|
prev_defn = @own_arguments[arg_defn.name]
|
|
@@ -98,7 +121,12 @@ module GraphQL
|
|
|
98
121
|
nil
|
|
99
122
|
end
|
|
100
123
|
|
|
101
|
-
#
|
|
124
|
+
# **Returns**
|
|
125
|
+
#
|
|
126
|
+
# - `Hash<String => GraphQL::Schema::Argument>` — Arguments defined on this thing, keyed by name. Includes inherited definitions
|
|
127
|
+
#
|
|
128
|
+
# :call-seq:
|
|
129
|
+
# arguments(context:, _require_defined_arguments) -> Hash[String, GraphQL::Schema::Argument]
|
|
102
130
|
def arguments(context = GraphQL::Query::NullContext.instance, _require_defined_arguments = nil)
|
|
103
131
|
if !own_arguments.empty?
|
|
104
132
|
own_arguments_that_apply = {}
|
|
@@ -122,6 +150,8 @@ module GraphQL
|
|
|
122
150
|
child_class.extend(InheritedArguments)
|
|
123
151
|
end
|
|
124
152
|
|
|
153
|
+
#--
|
|
154
|
+
# @requires_ancestor: singleton(Object)
|
|
125
155
|
module InheritedArguments
|
|
126
156
|
def arguments(context = GraphQL::Query::NullContext.instance, require_defined_arguments = true)
|
|
127
157
|
own_arguments = super(context, require_defined_arguments)
|
|
@@ -145,7 +175,8 @@ module GraphQL
|
|
|
145
175
|
|
|
146
176
|
def all_argument_definitions
|
|
147
177
|
all_defns = {}
|
|
148
|
-
ancestors
|
|
178
|
+
all_ancestors = ancestors #: Array[untyped]
|
|
179
|
+
all_ancestors.reverse_each do |ancestor|
|
|
149
180
|
if ancestor.respond_to?(:own_arguments)
|
|
150
181
|
all_defns.merge!(ancestor.own_arguments)
|
|
151
182
|
end
|
|
@@ -159,7 +190,8 @@ module GraphQL
|
|
|
159
190
|
def get_argument(argument_name, context = GraphQL::Query::NullContext.instance)
|
|
160
191
|
warden = Warden.from_context(context)
|
|
161
192
|
skip_visible = context.respond_to?(:types) && context.types.is_a?(GraphQL::Schema::Visibility::Profile)
|
|
162
|
-
|
|
193
|
+
all_ancestors = ancestors #: Array[untyped]
|
|
194
|
+
for ancestor in all_ancestors
|
|
163
195
|
if ancestor.respond_to?(:own_arguments) &&
|
|
164
196
|
(a = ancestor.own_arguments[argument_name]) &&
|
|
165
197
|
(skip_visible || (a = Warden.visible_entry?(:visible_argument?, a, context, warden)))
|
|
@@ -171,6 +203,9 @@ module GraphQL
|
|
|
171
203
|
end
|
|
172
204
|
end
|
|
173
205
|
|
|
206
|
+
#--
|
|
207
|
+
# @requires_ancestor: Kernel
|
|
208
|
+
# @requires_ancestor: GraphQL::Schema::Member::HasArguments
|
|
174
209
|
module FieldConfigured
|
|
175
210
|
def arguments(context = GraphQL::Query::NullContext.instance, _require_defined_arguments = nil)
|
|
176
211
|
own_arguments = super
|
|
@@ -230,7 +265,12 @@ module GraphQL
|
|
|
230
265
|
end
|
|
231
266
|
end
|
|
232
267
|
|
|
233
|
-
#
|
|
268
|
+
# **Returns**
|
|
269
|
+
#
|
|
270
|
+
# - `GraphQL::Schema::Argument, nil` — Argument defined on this thing, fetched by name.
|
|
271
|
+
#
|
|
272
|
+
# :call-seq:
|
|
273
|
+
# get_argument(argument_name, context:) -> GraphQL::Schema::Argument | nil
|
|
234
274
|
def get_argument(argument_name, context = GraphQL::Query::NullContext.instance)
|
|
235
275
|
warden = Warden.from_context(context)
|
|
236
276
|
if (arg_config = own_arguments[argument_name]) && ((context.respond_to?(:types) && context.types.is_a?(GraphQL::Schema::Visibility::Profile)) || (visible_arg = Warden.visible_entry?(:visible_argument?, arg_config, context, warden)))
|
|
@@ -242,26 +282,32 @@ module GraphQL
|
|
|
242
282
|
end
|
|
243
283
|
end
|
|
244
284
|
|
|
245
|
-
#
|
|
285
|
+
# **Parameters**
|
|
286
|
+
#
|
|
287
|
+
# - `new_arg_class` (`Class`) — A class to use for building argument definitions
|
|
288
|
+
#
|
|
289
|
+
# :call-seq:
|
|
290
|
+
# argument_class(Class new_arg_class)
|
|
246
291
|
def argument_class(new_arg_class = nil)
|
|
247
292
|
self.class.argument_class(new_arg_class)
|
|
248
293
|
end
|
|
249
294
|
|
|
250
|
-
#
|
|
251
|
-
# If given a block, it will eventually yield the loaded args to the block.
|
|
295
|
+
# **Yields:** [Interpreter::Arguments, Execution::Lazy<Interpreter::Arguments>]
|
|
252
296
|
#
|
|
253
|
-
#
|
|
297
|
+
# **Parameters**
|
|
254
298
|
#
|
|
255
|
-
#
|
|
256
|
-
#
|
|
257
|
-
#
|
|
258
|
-
#
|
|
259
|
-
|
|
299
|
+
# - `values` (`Hash<String, Object>`)
|
|
300
|
+
# - `context` (`GraphQL::Query::Context`)
|
|
301
|
+
#
|
|
302
|
+
# **Returns**
|
|
303
|
+
#
|
|
304
|
+
# - `Interpreter::Arguments, Execution::Lazy<Interpreter::Arguments>`
|
|
305
|
+
def coerce_arguments(parent_object, values, context, &block) # :nodoc:
|
|
260
306
|
# Cache this hash to avoid re-merging it
|
|
261
307
|
arg_defns = context.types.arguments(self)
|
|
262
308
|
total_args_count = arg_defns.size
|
|
263
309
|
|
|
264
|
-
finished_args = nil
|
|
310
|
+
finished_args = nil #: untyped
|
|
265
311
|
prepare_finished_args = -> {
|
|
266
312
|
if total_args_count == 0
|
|
267
313
|
finished_args = GraphQL::Execution::Interpreter::Arguments::EMPTY
|
|
@@ -271,7 +317,7 @@ module GraphQL
|
|
|
271
317
|
else
|
|
272
318
|
argument_values = {}
|
|
273
319
|
resolved_args_count = 0
|
|
274
|
-
raised_error = false
|
|
320
|
+
raised_error = false #: bool
|
|
275
321
|
arg_defns.each do |arg_defn|
|
|
276
322
|
context.dataloader.append_job do
|
|
277
323
|
begin
|
|
@@ -318,6 +364,8 @@ module GraphQL
|
|
|
318
364
|
nil
|
|
319
365
|
end
|
|
320
366
|
|
|
367
|
+
#--
|
|
368
|
+
# @requires_ancestor: Kernel
|
|
321
369
|
module HasDirectiveArguments
|
|
322
370
|
def validate_directive_argument(arg_defn, value)
|
|
323
371
|
if value.nil? && arg_defn.type.non_null?
|
|
@@ -334,6 +382,8 @@ module GraphQL
|
|
|
334
382
|
end
|
|
335
383
|
end
|
|
336
384
|
|
|
385
|
+
#--
|
|
386
|
+
# @requires_ancestor: singleton(Object)
|
|
337
387
|
module ArgumentClassAccessor
|
|
338
388
|
def argument_class(new_arg_class = nil)
|
|
339
389
|
if new_arg_class
|
|
@@ -346,14 +396,21 @@ module GraphQL
|
|
|
346
396
|
end
|
|
347
397
|
end
|
|
348
398
|
|
|
399
|
+
#--
|
|
400
|
+
# @requires_ancestor: Kernel
|
|
349
401
|
module ArgumentObjectLoader
|
|
350
402
|
# Look up the corresponding object for a provided ID.
|
|
351
|
-
# By default, it uses Relay-style
|
|
403
|
+
# By default, it uses Relay-style [Schema.object_from_id](rdoc-ref:Schema.object_from_id),
|
|
352
404
|
# override this to find objects another way.
|
|
353
405
|
#
|
|
354
|
-
#
|
|
355
|
-
#
|
|
356
|
-
#
|
|
406
|
+
# **Parameters**
|
|
407
|
+
#
|
|
408
|
+
# - `type` (`Class, Module`) — A GraphQL type definition
|
|
409
|
+
# - `id` (`String`) — A client-provided to look up
|
|
410
|
+
# - `context` (`GraphQL::Query::Context`) — the current context
|
|
411
|
+
#
|
|
412
|
+
# :call-seq:
|
|
413
|
+
# object_from_id(Class | Module type, String id, GraphQL::Query::Context context)
|
|
357
414
|
def object_from_id(type, id, context)
|
|
358
415
|
context.schema.object_from_id(id, context)
|
|
359
416
|
end
|
|
@@ -374,7 +431,7 @@ module GraphQL
|
|
|
374
431
|
def authorize_application_object(argument, id, context, loaded_application_object)
|
|
375
432
|
context.query.after_lazy(loaded_application_object) do |application_object|
|
|
376
433
|
if application_object.nil?
|
|
377
|
-
err = GraphQL::LoadApplicationObjectFailedError.new(context: context, argument: argument, id: id, object: application_object)
|
|
434
|
+
err = GraphQL::LoadApplicationObjectFailedError.new(context: context, argument: argument, id: id, object: application_object) #: GraphQL::RuntimeError
|
|
378
435
|
application_object = load_application_object_failed(err)
|
|
379
436
|
end
|
|
380
437
|
# Double-check that the located object is actually of this type
|
|
@@ -424,7 +481,8 @@ module GraphQL
|
|
|
424
481
|
)
|
|
425
482
|
if self.respond_to?(:unauthorized_object)
|
|
426
483
|
err.set_backtrace(caller)
|
|
427
|
-
|
|
484
|
+
loader = self #: untyped
|
|
485
|
+
loader.unauthorized_object(err)
|
|
428
486
|
else
|
|
429
487
|
raise err
|
|
430
488
|
end
|
|
@@ -439,9 +497,18 @@ module GraphQL
|
|
|
439
497
|
# Called when an argument's `loads:` configuration fails to fetch an application object.
|
|
440
498
|
# By default, this method raises the given error, but you can override it to handle failures differently.
|
|
441
499
|
#
|
|
442
|
-
#
|
|
443
|
-
#
|
|
444
|
-
#
|
|
500
|
+
# **API:** public
|
|
501
|
+
#
|
|
502
|
+
# **Parameters**
|
|
503
|
+
#
|
|
504
|
+
# - `err` (`GraphQL::LoadApplicationObjectFailedError`) — The error that occurred
|
|
505
|
+
#
|
|
506
|
+
# **Returns**
|
|
507
|
+
#
|
|
508
|
+
# - `Object, nil` — If a value is returned, it will be used instead of the failed load
|
|
509
|
+
#
|
|
510
|
+
# :call-seq:
|
|
511
|
+
# load_application_object_failed(GraphQL::LoadApplicationObjectFailedError err) -> Object | nil
|
|
445
512
|
def load_application_object_failed(err)
|
|
446
513
|
raise err
|
|
447
514
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Schema
|
|
4
5
|
class Member
|
|
@@ -18,12 +19,16 @@ module GraphQL
|
|
|
18
19
|
true
|
|
19
20
|
end
|
|
20
21
|
|
|
22
|
+
#--
|
|
23
|
+
# @requires_ancestor: Kernel
|
|
21
24
|
module InstanceConfigured
|
|
22
25
|
def authorizes?(context)
|
|
23
26
|
raise RequiredImplementationMissingError, "#{self.class} must implement #authorizes?(context)"
|
|
24
27
|
end
|
|
25
28
|
end
|
|
26
29
|
|
|
30
|
+
#--
|
|
31
|
+
# @requires_ancestor: Kernel
|
|
27
32
|
module ClassConfigured
|
|
28
33
|
def authorizes?(context)
|
|
29
34
|
method(:authorized?).owner != GraphQL::Schema::Member::HasAuthorization
|