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,60 +1,80 @@
|
|
|
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
|
# Shared code for Objects, Interfaces, Mutations, Subscriptions
|
|
8
|
+
#--
|
|
9
|
+
# @requires_ancestor: Kernel
|
|
10
|
+
# @requires_ancestor: Module
|
|
11
|
+
# @requires_ancestor: GraphQL::Schema::Member::BaseDSLMethods
|
|
7
12
|
module HasFields
|
|
8
13
|
include EmptyObjects
|
|
9
14
|
# Add a field to this object or interface with the given definition
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
15
|
+
#
|
|
16
|
+
# **Parameters**
|
|
17
|
+
#
|
|
18
|
+
# - `name_positional` (`Symbol`) — The underscore-cased version of this field name (will be camelized for the GraphQL API); `name:` keyword is also accepted
|
|
19
|
+
# - `type_positional` (`Class, GraphQL::BaseType, Array`) — The return type of this field; `type:` keyword is also accepted
|
|
20
|
+
# - `desc_positional` (`String`) — Field description; `description:` keyword is also accepted
|
|
21
|
+
# - `kwargs` (`Hash`) — Keywords for defining the field. Any not documented here will be passed to your base field class where they must be handled.
|
|
22
|
+
# - `definition_block` (`Proc`) — an additional block for configuring the field. Receive the field as a block param, or, if no block params are defined, then the block is `instance_eval`'d on the new [Field](rdoc-ref:Field).
|
|
23
|
+
#
|
|
24
|
+
# **Options**
|
|
25
|
+
#
|
|
26
|
+
# - `kwargs.:name` (`Symbol`) — The underscore-cased version of this field name (will be camelized for the GraphQL API); positional argument also accepted
|
|
27
|
+
# - `kwargs.:type` (`Class, GraphQL::BaseType, Array`) — The return type of this field; positional argument is also accepted
|
|
28
|
+
# - `kwargs.:null` (`Boolean`) — (defaults to `true`) `true` if this field may return `null`, `false` if it is never `null`
|
|
29
|
+
# - `kwargs.:description` (`String`) — Field description; positional argument also accepted
|
|
30
|
+
# - `kwargs.:comment` (`String`) — Field comment
|
|
31
|
+
# - `kwargs.:deprecation_reason` (`String`) — If present, the field is marked "deprecated" with this message
|
|
32
|
+
# - `kwargs.:method` (`Symbol`) — The method to call on the underlying object to resolve this field (defaults to `name`)
|
|
33
|
+
# - `kwargs.:hash_key` (`String, Symbol`) — The hash key to lookup on the underlying object (if its a Hash) to resolve this field (defaults to `name` or `name.to_s`)
|
|
34
|
+
# - `kwargs.:dig` (`Array<String, Symbol>`) — The nested hash keys to lookup on the underlying hash to resolve this field using dig
|
|
35
|
+
# - `kwargs.:resolver_method` (`Symbol, true`) — The method on the type to call to resolve this field (defaults to `name`)
|
|
36
|
+
# - `kwargs.:resolve_static` (`Symbol, true`) — Used by `Schema.execute_next` to produce a single value, shared by all objects which resolve this field. Called on the owner type class with `context, **arguments`
|
|
37
|
+
# - `kwargs.:resolve_batch` (`Symbol, true`) — Used by `Schema.execute_next` map `objects` to a same-sized Array of results. Called on the owner type class with `objects, context, **arguments`.
|
|
38
|
+
# - `kwargs.:resolve_each` (`Symbol, true`) — Used by `Schema.execute_next` to get a value value for each item. Called on the owner type class with `object, context, **arguments`.
|
|
39
|
+
# - `kwargs.:resolve_legacy_instance_method` (`Symbol, true`) — Used by `Schema.execute_next` to get a value value for each item. Calls an instance method on the object type class.
|
|
40
|
+
# - `kwargs.:connection` (`Boolean`) — `true` if this field should get automagic connection behavior; default is to infer by `*Connection` in the return type name
|
|
41
|
+
# - `kwargs.:connection_extension` (`Class`) — The extension to add, to implement connections. If `nil`, no extension is added.
|
|
42
|
+
# - `kwargs.:max_page_size` (`Integer, nil`) — For connections, the maximum number of items to return from this field, or `nil` to allow unlimited results.
|
|
43
|
+
# - `kwargs.:default_page_size` (`Integer, nil`) — For connections, the default number of items to return from this field, or `nil` to return unlimited results.
|
|
44
|
+
# - `kwargs.:introspection` (`Boolean`) — If true, this field will be marked as `#introspection?` and the name may begin with `__`
|
|
45
|
+
# - `kwargs.:arguments` (`{String=>GraphQL::Schema::Argument, Hash}`) — Arguments for this field (may be added in the block, also)
|
|
46
|
+
# - `kwargs.:camelize` (`Boolean`) — If true, the field name will be camelized when building the schema
|
|
47
|
+
# - `kwargs.:complexity` (`Numeric`) — When provided, set the complexity for this field
|
|
48
|
+
# - `kwargs.:scope` (`Boolean`) — If true, the return type's `.scope_items` method will be called on the return value
|
|
49
|
+
# - `kwargs.:subscription_scope` (`Symbol, String`) — A key in `context` which will be used to scope subscription payloads
|
|
50
|
+
# - `kwargs.:extensions` (`Array<Class, Hash<Class => Object>>`) — Named extensions to apply to this field (see also [Field#extension](rdoc-ref:GraphQL::Schema::Field#extension))
|
|
51
|
+
# - `kwargs.:directives` (`Hash{Class => Hash}`) — Directives to apply to this field
|
|
52
|
+
# - `kwargs.:trace` (`Boolean`) — If true, a [GraphQL::Tracing](rdoc-ref:GraphQL::Tracing) tracer will measure this scalar field
|
|
53
|
+
# - `kwargs.:broadcastable` (`Boolean`) — Whether or not this field can be distributed in subscription broadcasts
|
|
54
|
+
# - `kwargs.:ast_node` (`Language::Nodes::FieldDefinition, nil`) — If this schema was parsed from definition, this AST node defined the field
|
|
55
|
+
# - `kwargs.:method_conflict_warning` (`Boolean`) — If false, skip the warning if this field's method conflicts with a built-in method
|
|
56
|
+
# - `kwargs.:validates` (`Array<Hash>`) — Configurations for validating this field
|
|
57
|
+
# - `kwargs.:fallback_value` (`Object`) — A fallback value if the method is not defined
|
|
58
|
+
# - `kwargs.:mutation` (`Class<GraphQL::Schema::Mutation>`)
|
|
59
|
+
# - `kwargs.:resolver` (`Class<GraphQL::Schema::Resolver>`)
|
|
60
|
+
# - `kwargs.:subscription` (`Class<GraphQL::Schema::Subscription>`)
|
|
61
|
+
# - `kwargs.:dynamic_introspection` (`Boolean`) — (Private, used by GraphQL-Ruby)
|
|
62
|
+
# - `kwargs.:relay_node_field` (`Boolean`) — (Private, used by GraphQL-Ruby)
|
|
63
|
+
# - `kwargs.:relay_nodes_field` (`Boolean`) — (Private, used by GraphQL-Ruby)
|
|
64
|
+
# - `kwargs.:dataload` (`Class, Hash`) — Shorthand for dataloader lookups
|
|
65
|
+
# - `kwargs.:extras` (`Array<:ast_node, :parent, :lookahead, :owner, :execution_errors, :graphql_name, :argument_details, Symbol>`) — Extra arguments to be injected into the resolver for this field
|
|
66
|
+
#
|
|
67
|
+
# **Yields**
|
|
68
|
+
#
|
|
69
|
+
# - `field` (`GraphQL::Schema::Field`) — The newly-created field instance
|
|
70
|
+
# - `void`
|
|
71
|
+
#
|
|
72
|
+
# **Returns**
|
|
73
|
+
#
|
|
74
|
+
# - `GraphQL::Schema::Field`
|
|
75
|
+
#
|
|
76
|
+
# :call-seq:
|
|
77
|
+
# field(Symbol name_positional, Class | GraphQL::BaseType | Array type_positional, String desc_positional, Hash **kwargs, Proc &definition_block) -> GraphQL::Schema::Field
|
|
58
78
|
def field(name_positional = nil, type_positional = nil, desc_positional = nil, **kwargs, &definition_block)
|
|
59
79
|
resolver = kwargs.delete(:resolver)
|
|
60
80
|
mutation = kwargs.delete(:mutation)
|
|
@@ -93,23 +113,32 @@ module GraphQL
|
|
|
93
113
|
|
|
94
114
|
# A list of Ruby keywords.
|
|
95
115
|
#
|
|
96
|
-
#
|
|
116
|
+
# :nodoc:
|
|
97
117
|
RUBY_KEYWORDS = [:class, :module, :def, :undef, :begin, :rescue, :ensure, :end, :if, :unless, :then, :elsif, :else, :case, :when, :while, :until, :for, :break, :next, :redo, :retry, :in, :do, :return, :yield, :super, :self, :nil, :true, :false, :and, :or, :not, :alias, :defined?, :BEGIN, :END, :__LINE__, :__FILE__]
|
|
98
118
|
|
|
99
119
|
# A list of GraphQL-Ruby keywords.
|
|
100
120
|
#
|
|
101
|
-
#
|
|
121
|
+
# :nodoc:
|
|
102
122
|
GRAPHQL_RUBY_KEYWORDS = [:context, :object, :raw_value]
|
|
103
123
|
|
|
104
124
|
# A list of field names that we should advise users to pick a different
|
|
105
125
|
# resolve method name.
|
|
106
126
|
#
|
|
107
|
-
#
|
|
127
|
+
# :nodoc:
|
|
108
128
|
CONFLICT_FIELD_NAMES = Set.new(GRAPHQL_RUBY_KEYWORDS + RUBY_KEYWORDS + Object.instance_methods)
|
|
109
129
|
|
|
110
130
|
# Register this field with the class, overriding a previous one if needed.
|
|
111
|
-
#
|
|
112
|
-
#
|
|
131
|
+
#
|
|
132
|
+
# **Parameters**
|
|
133
|
+
#
|
|
134
|
+
# - `field_defn` (`GraphQL::Schema::Field`)
|
|
135
|
+
#
|
|
136
|
+
# **Returns**
|
|
137
|
+
#
|
|
138
|
+
# - `void`
|
|
139
|
+
#
|
|
140
|
+
# :call-seq:
|
|
141
|
+
# add_field(GraphQL::Schema::Field field_defn, method_conflict_warning:) -> void
|
|
113
142
|
def add_field(field_defn, method_conflict_warning: field_defn.method_conflict_warning?)
|
|
114
143
|
# Check that `field_defn.original_name` equals `resolver_method` and `method_sym` --
|
|
115
144
|
# that shows that no override value was given manually.
|
|
@@ -137,7 +166,12 @@ module GraphQL
|
|
|
137
166
|
nil
|
|
138
167
|
end
|
|
139
168
|
|
|
140
|
-
#
|
|
169
|
+
# **Returns**
|
|
170
|
+
#
|
|
171
|
+
# - `Class` — The class to initialize when adding fields to this kind of schema member
|
|
172
|
+
#
|
|
173
|
+
# :call-seq:
|
|
174
|
+
# field_class(new_field_class) -> Class
|
|
141
175
|
def field_class(new_field_class = nil)
|
|
142
176
|
if new_field_class
|
|
143
177
|
@field_class = new_field_class
|
|
@@ -152,6 +186,7 @@ module GraphQL
|
|
|
152
186
|
type = self
|
|
153
187
|
field field_name, "ID", **kwargs, null: false, resolve_each: true
|
|
154
188
|
define_method(field_name) do
|
|
189
|
+
#: self as GraphQL::Schema::Object
|
|
155
190
|
context.schema.id_from_object(object, type, context)
|
|
156
191
|
end
|
|
157
192
|
|
|
@@ -160,26 +195,45 @@ module GraphQL
|
|
|
160
195
|
end
|
|
161
196
|
end
|
|
162
197
|
|
|
163
|
-
#
|
|
164
|
-
#
|
|
198
|
+
# **Parameters**
|
|
199
|
+
#
|
|
200
|
+
# - `new_has_no_fields` (`Boolean`) — Call with `true` to make this Object type ignore the requirement to have any defined fields.
|
|
201
|
+
#
|
|
202
|
+
# **Returns**
|
|
203
|
+
#
|
|
204
|
+
# - `void`
|
|
205
|
+
#
|
|
206
|
+
# :call-seq:
|
|
207
|
+
# has_no_fields(bool new_has_no_fields) -> void
|
|
165
208
|
def has_no_fields(new_has_no_fields)
|
|
166
209
|
@has_no_fields = new_has_no_fields
|
|
167
210
|
nil
|
|
168
211
|
end
|
|
169
212
|
|
|
170
|
-
#
|
|
213
|
+
# **Returns**
|
|
214
|
+
#
|
|
215
|
+
# - `Boolean` — `true` if `has_no_fields(true)` was configued
|
|
216
|
+
#
|
|
217
|
+
# :call-seq:
|
|
218
|
+
# has_no_fields?() -> bool
|
|
171
219
|
def has_no_fields?
|
|
172
220
|
@has_no_fields
|
|
173
221
|
end
|
|
174
222
|
|
|
175
|
-
#
|
|
223
|
+
# **Returns**
|
|
224
|
+
#
|
|
225
|
+
# - `Hash<String => GraphQL::Schema::Field, Array<GraphQL::Schema::Field>>` — Fields defined on this class _specifically_, not parent classes
|
|
226
|
+
#
|
|
227
|
+
# :call-seq:
|
|
228
|
+
# own_fields() -> Hash[String, GraphQL::Schema::Field | Array[GraphQL::Schema::Field]]
|
|
176
229
|
def own_fields
|
|
177
230
|
@own_fields ||= {}
|
|
178
231
|
end
|
|
179
232
|
|
|
180
233
|
def all_field_definitions
|
|
181
234
|
all_fields = {}
|
|
182
|
-
ancestors
|
|
235
|
+
all_ancestors = ancestors #: Array[untyped]
|
|
236
|
+
all_ancestors.reverse_each do |ancestor|
|
|
183
237
|
if ancestor.respond_to?(:own_fields)
|
|
184
238
|
all_fields.merge!(ancestor.own_fields)
|
|
185
239
|
end
|
|
@@ -189,11 +243,14 @@ module GraphQL
|
|
|
189
243
|
all_fields
|
|
190
244
|
end
|
|
191
245
|
|
|
246
|
+
#--
|
|
247
|
+
# @requires_ancestor: Module
|
|
192
248
|
module InterfaceMethods
|
|
193
249
|
def get_field(field_name, context = GraphQL::Query::NullContext.instance)
|
|
194
250
|
warden = Warden.from_context(context)
|
|
195
251
|
skip_visible = context.respond_to?(:types) && context.types.is_a?(GraphQL::Schema::Visibility::Profile)
|
|
196
|
-
|
|
252
|
+
all_ancestors = ancestors #: Array[untyped]
|
|
253
|
+
for ancestor in all_ancestors
|
|
197
254
|
if ancestor.respond_to?(:own_fields) &&
|
|
198
255
|
(f_entry = ancestor.own_fields[field_name]) &&
|
|
199
256
|
(skip_visible || (f_entry = Warden.visible_entry?(:visible_field?, f_entry, context, warden)))
|
|
@@ -203,12 +260,18 @@ module GraphQL
|
|
|
203
260
|
nil
|
|
204
261
|
end
|
|
205
262
|
|
|
206
|
-
#
|
|
263
|
+
# **Returns**
|
|
264
|
+
#
|
|
265
|
+
# - `Hash<String => GraphQL::Schema::Field>` — Fields on this object, keyed by name, including inherited fields
|
|
266
|
+
#
|
|
267
|
+
# :call-seq:
|
|
268
|
+
# fields(context:) -> Hash[String, GraphQL::Schema::Field]
|
|
207
269
|
def fields(context = GraphQL::Query::NullContext.instance)
|
|
208
270
|
warden = Warden.from_context(context)
|
|
209
271
|
# Local overrides take precedence over inherited fields
|
|
210
272
|
visible_fields = {}
|
|
211
|
-
|
|
273
|
+
all_ancestors = ancestors #: Array[untyped]
|
|
274
|
+
for ancestor in all_ancestors
|
|
212
275
|
if ancestor.respond_to?(:own_fields)
|
|
213
276
|
ancestor.own_fields.each do |field_name, fields_entry|
|
|
214
277
|
# Choose the most local definition that passes `.visible?` --
|
|
@@ -223,11 +286,15 @@ module GraphQL
|
|
|
223
286
|
end
|
|
224
287
|
end
|
|
225
288
|
|
|
289
|
+
#--
|
|
290
|
+
# @requires_ancestor: Kernel
|
|
291
|
+
# @requires_ancestor: Module
|
|
292
|
+
# @requires_ancestor: GraphQL::Schema::Member::HasFields
|
|
226
293
|
module ObjectMethods
|
|
227
294
|
def get_field(field_name, context = GraphQL::Query::NullContext.instance)
|
|
228
295
|
# Objects need to check that the interface implementation is visible, too
|
|
229
296
|
warden = Warden.from_context(context)
|
|
230
|
-
ancs = ancestors
|
|
297
|
+
ancs = ancestors #: Array[untyped]
|
|
231
298
|
skip_visible = context.respond_to?(:types) && context.types.is_a?(GraphQL::Schema::Visibility::Profile)
|
|
232
299
|
i = 0
|
|
233
300
|
while (ancestor = ancs[i])
|
|
@@ -242,14 +309,20 @@ module GraphQL
|
|
|
242
309
|
nil
|
|
243
310
|
end
|
|
244
311
|
|
|
245
|
-
#
|
|
312
|
+
# **Returns**
|
|
313
|
+
#
|
|
314
|
+
# - `Hash<String => GraphQL::Schema::Field>` — Fields on this object, keyed by name, including inherited fields
|
|
315
|
+
#
|
|
316
|
+
# :call-seq:
|
|
317
|
+
# fields(context:) -> Hash[String, GraphQL::Schema::Field]
|
|
246
318
|
def fields(context = GraphQL::Query::NullContext.instance)
|
|
247
319
|
# Objects need to check that the interface implementation is visible, too
|
|
248
320
|
warden = Warden.from_context(context)
|
|
249
321
|
# Local overrides take precedence over inherited fields
|
|
250
322
|
visible_fields = {}
|
|
251
|
-
had_any_fields_at_all = false
|
|
252
|
-
|
|
323
|
+
had_any_fields_at_all = false #: bool
|
|
324
|
+
all_ancestors = ancestors #: Array[untyped]
|
|
325
|
+
for ancestor in all_ancestors
|
|
253
326
|
if ancestor.respond_to?(:own_fields) && visible_interface_implementation?(ancestor, context, warden)
|
|
254
327
|
ancestor.own_fields.each do |field_name, fields_entry|
|
|
255
328
|
had_any_fields_at_all = true
|
|
@@ -293,8 +366,8 @@ module GraphQL
|
|
|
293
366
|
# If `type` is an interface, and `self` has a type membership for `type`, then make sure it's visible.
|
|
294
367
|
def visible_interface_implementation?(type, context, warden)
|
|
295
368
|
if type.respond_to?(:kind) && type.kind.interface?
|
|
296
|
-
implements_this_interface = false
|
|
297
|
-
implementation_is_visible = false
|
|
369
|
+
implements_this_interface = false #: bool
|
|
370
|
+
implementation_is_visible = false #: bool
|
|
298
371
|
warden.interface_type_memberships(self, context).each do |tm|
|
|
299
372
|
if tm.abstract_type == type
|
|
300
373
|
implements_this_interface ||= true
|
|
@@ -313,8 +386,16 @@ module GraphQL
|
|
|
313
386
|
end
|
|
314
387
|
end
|
|
315
388
|
|
|
316
|
-
#
|
|
317
|
-
#
|
|
389
|
+
# **Parameters**
|
|
390
|
+
#
|
|
391
|
+
# - `field_defn` (`GraphQL::Schema::Field`)
|
|
392
|
+
#
|
|
393
|
+
# **Returns**
|
|
394
|
+
#
|
|
395
|
+
# - `String` — A warning to give when this field definition might conflict with a built-in method
|
|
396
|
+
#
|
|
397
|
+
# :call-seq:
|
|
398
|
+
# conflict_field_name_warning(GraphQL::Schema::Field field_defn) -> String
|
|
318
399
|
def conflict_field_name_warning(field_defn)
|
|
319
400
|
"#{self.graphql_name}'s `field :#{field_defn.original_name}` conflicts with a built-in method, use `resolver_method:` to pick a different resolver method for this field (for example, `resolver_method: :resolve_#{field_defn.resolver_method}` and `def resolve_#{field_defn.resolver_method}`). Or use `method_conflict_warning: false` to suppress this warning."
|
|
320
401
|
end
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
5
6
|
class Member
|
|
7
|
+
#--
|
|
8
|
+
# @requires_ancestor: Kernel
|
|
9
|
+
# @requires_ancestor: Module
|
|
6
10
|
module HasInterfaces
|
|
7
11
|
def implements(*new_interfaces, **options)
|
|
8
12
|
new_memberships = []
|
|
9
13
|
new_interfaces.each do |int|
|
|
10
14
|
if int.is_a?(Module)
|
|
11
15
|
unless int.include?(GraphQL::Schema::Interface) && !int.is_a?(Class)
|
|
12
|
-
|
|
16
|
+
non_interface = int #: untyped
|
|
17
|
+
raise "#{non_interface.respond_to?(:graphql_name) ? "#{non_interface.graphql_name} (#{non_interface})" : non_interface.inspect} cannot be implemented since it's not a GraphQL Interface. Use `include` for plain Ruby modules."
|
|
13
18
|
end
|
|
19
|
+
int = int #: as GraphQL::Schema::Member::interface_definition
|
|
14
20
|
|
|
15
21
|
new_memberships << int.type_membership_class.new(int, self, **options)
|
|
16
22
|
|
|
@@ -69,6 +75,8 @@ module GraphQL
|
|
|
69
75
|
child_class.extend(InheritedInterfaces)
|
|
70
76
|
end
|
|
71
77
|
|
|
78
|
+
#--
|
|
79
|
+
# @requires_ancestor: singleton(Object)
|
|
72
80
|
module InheritedInterfaces
|
|
73
81
|
def interfaces(context = GraphQL::Query::NullContext.instance)
|
|
74
82
|
visible_interfaces = super
|
|
@@ -101,7 +109,7 @@ module GraphQL
|
|
|
101
109
|
# param context [Query::Context] If omitted, skip filtering.
|
|
102
110
|
def interfaces(context = GraphQL::Query::NullContext.instance)
|
|
103
111
|
warden = Warden.from_context(context)
|
|
104
|
-
visible_interfaces = nil
|
|
112
|
+
visible_interfaces = nil #: Array[untyped]?
|
|
105
113
|
own_interface_type_memberships.each do |type_membership|
|
|
106
114
|
case type_membership
|
|
107
115
|
when Schema::TypeMembership
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
5
6
|
class Member
|
|
7
|
+
#--
|
|
8
|
+
# @requires_ancestor: Kernel
|
|
6
9
|
module HasPath
|
|
7
|
-
#
|
|
10
|
+
# **Returns**
|
|
11
|
+
#
|
|
12
|
+
# - `String` — A description of this member's place in the GraphQL schema
|
|
13
|
+
#
|
|
14
|
+
# :call-seq:
|
|
15
|
+
# path() -> String
|
|
8
16
|
def path
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
member = self #: untyped
|
|
18
|
+
path_str = if member.respond_to?(:graphql_name)
|
|
19
|
+
member.graphql_name
|
|
11
20
|
elsif self.class.respond_to?(:graphql_name)
|
|
12
21
|
# Instances of resolvers
|
|
13
22
|
self.class.graphql_name
|
|
14
23
|
end
|
|
15
24
|
|
|
16
|
-
if
|
|
17
|
-
path_str = "#{owner.path}.#{path_str}"
|
|
25
|
+
if member.respond_to?(:owner) && member.owner.respond_to?(:path)
|
|
26
|
+
path_str = "#{member.owner.path}.#{path_str}"
|
|
18
27
|
end
|
|
19
28
|
|
|
20
29
|
path_str
|
|
@@ -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
|
module HasValidators
|
|
6
7
|
include GraphQL::EmptyObjects
|
|
7
8
|
|
|
8
|
-
# Build
|
|
9
|
+
# Build [GraphQL::Schema::Validator](rdoc-ref:GraphQL::Schema::Validator)s based on the given configuration
|
|
9
10
|
# and use them for this schema member
|
|
10
|
-
#
|
|
11
|
-
#
|
|
11
|
+
#
|
|
12
|
+
# **Parameters**
|
|
13
|
+
#
|
|
14
|
+
# - `validation_config` (`Hash{Symbol => Hash}`)
|
|
15
|
+
#
|
|
16
|
+
# **Returns**
|
|
17
|
+
#
|
|
18
|
+
# - `void`
|
|
19
|
+
#
|
|
20
|
+
# :call-seq:
|
|
21
|
+
# validates(Hash[Symbol, Hash] validation_config) -> void
|
|
12
22
|
def validates(validation_config)
|
|
13
23
|
new_validators = GraphQL::Schema::Validator.from_config(self, validation_config)
|
|
14
24
|
@own_validators ||= []
|
|
@@ -16,7 +26,12 @@ module GraphQL
|
|
|
16
26
|
nil
|
|
17
27
|
end
|
|
18
28
|
|
|
19
|
-
#
|
|
29
|
+
# **Returns**
|
|
30
|
+
#
|
|
31
|
+
# - `Array<GraphQL::Schema::Validator>`
|
|
32
|
+
#
|
|
33
|
+
# :call-seq:
|
|
34
|
+
# validators() -> Array[GraphQL::Schema::Validator]
|
|
20
35
|
def validators
|
|
21
36
|
@own_validators || EMPTY_ARRAY
|
|
22
37
|
end
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
5
6
|
class Member
|
|
7
|
+
#--
|
|
8
|
+
# @requires_ancestor: Module
|
|
9
|
+
# @requires_ancestor: GraphQL::Schema::Member::BaseDSLMethods
|
|
6
10
|
module RelayShortcuts
|
|
7
11
|
def edge_type_class(new_edge_type_class = nil)
|
|
8
12
|
if new_edge_type_class
|
|
@@ -12,7 +16,8 @@ module GraphQL
|
|
|
12
16
|
# Don't call `ancestor.edge_type_class`
|
|
13
17
|
# because we don't want a fallback from any ancestors --
|
|
14
18
|
# only apply the fallback if _no_ ancestor has a configured value!
|
|
15
|
-
|
|
19
|
+
all_ancestors = self.ancestors #: Array[untyped]
|
|
20
|
+
for ancestor in all_ancestors
|
|
16
21
|
if ancestor.respond_to?(:configured_edge_type_class, true) && (etc = ancestor.configured_edge_type_class)
|
|
17
22
|
return etc
|
|
18
23
|
end
|
|
@@ -29,7 +34,8 @@ module GraphQL
|
|
|
29
34
|
# Don't call `ancestor.connection_type_class`
|
|
30
35
|
# because we don't want a fallback from any ancestors --
|
|
31
36
|
# only apply the fallback if _no_ ancestor has a configured value!
|
|
32
|
-
|
|
37
|
+
all_ancestors = self.ancestors #: Array[untyped]
|
|
38
|
+
for ancestor in all_ancestors
|
|
33
39
|
if ancestor.respond_to?(:configured_connection_type_class, true) && (ctc = ancestor.configured_connection_type_class)
|
|
34
40
|
return ctc
|
|
35
41
|
end
|
|
@@ -44,6 +50,7 @@ module GraphQL
|
|
|
44
50
|
edge_name = self.graphql_name + "Edge"
|
|
45
51
|
node_type_class = self
|
|
46
52
|
Class.new(edge_type_class) do
|
|
53
|
+
#: self as untyped
|
|
47
54
|
graphql_name(edge_name)
|
|
48
55
|
node_type(node_type_class)
|
|
49
56
|
end
|
|
@@ -56,6 +63,7 @@ module GraphQL
|
|
|
56
63
|
conn_name = self.graphql_name + "Connection"
|
|
57
64
|
edge_type_class = self.edge_type
|
|
58
65
|
Class.new(connection_type_class) do
|
|
66
|
+
#: self as untyped
|
|
59
67
|
graphql_name(conn_name)
|
|
60
68
|
edge_type(edge_type_class)
|
|
61
69
|
end
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
5
6
|
class Member
|
|
7
|
+
#--
|
|
8
|
+
# @requires_ancestor: GraphQL::Schema::FindInheritedValue
|
|
6
9
|
module Scoped
|
|
7
10
|
# This is called when a field has `scope: true`.
|
|
8
11
|
# The field's return type class receives this call.
|
|
9
12
|
#
|
|
10
13
|
# By default, it's a no-op. Override it to scope your objects.
|
|
11
14
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
+
# **Parameters**
|
|
16
|
+
#
|
|
17
|
+
# - `items` (`Object`) — Some list-like object (eg, Array, ActiveRecord::Relation)
|
|
18
|
+
# - `context` (`GraphQL::Query::Context`)
|
|
19
|
+
#
|
|
20
|
+
# **Returns**
|
|
21
|
+
#
|
|
22
|
+
# - `Object` — Another list-like object, scoped to the current context
|
|
23
|
+
#
|
|
24
|
+
# :call-seq:
|
|
25
|
+
# scope_items(Object items, GraphQL::Query::Context context) -> Object
|
|
15
26
|
def scope_items(items, context)
|
|
16
27
|
items
|
|
17
28
|
end
|