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
data/lib/graphql/schema/field.rb
CHANGED
|
@@ -1,9 +1,279 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require "graphql/schema/field/connection_extension"
|
|
3
4
|
require "graphql/schema/field/scope_extension"
|
|
4
5
|
|
|
5
6
|
module GraphQL
|
|
6
7
|
class Schema
|
|
8
|
+
# Field definitions are the primary way to expose data from an object type.
|
|
9
|
+
# Keep field-specific behavior and examples here; the guide is only an
|
|
10
|
+
# entry point for the broader fields documentation.
|
|
11
|
+
#
|
|
12
|
+
# Object fields expose data about that object or connect the object to other objects. You can add fields to your object types with the `field(...)` class method, for example:
|
|
13
|
+
#
|
|
14
|
+
# ```ruby
|
|
15
|
+
# field :name, String, "The unique name of this list", null: false
|
|
16
|
+
# ```
|
|
17
|
+
#
|
|
18
|
+
# [Objects](/type_definitions/objects) and [Interfaces](/type_definitions/interfaces) have fields.
|
|
19
|
+
#
|
|
20
|
+
# The different elements of field definition are addressed below:
|
|
21
|
+
#
|
|
22
|
+
# - [Names](#class-graphql-schema-field-field-names) identify the field in GraphQL
|
|
23
|
+
# - [Return types](#class-graphql-schema-field-field-return-type) say what kind of data this field returns
|
|
24
|
+
# - [Documentation](#class-graphql-schema-field-field-documentation) includes description, comments and deprecation notes
|
|
25
|
+
# - [Resolution behavior](#class-graphql-schema-field-field-resolution) hooks up the GraphQL field to Ruby code
|
|
26
|
+
# - [Arguments](#class-graphql-schema-field-field-arguments) allow fields to take input when they're queried
|
|
27
|
+
# - [Extra field metadata](#class-graphql-schema-field-extra-field-metadata) for low-level access to the GraphQL-Ruby runtime
|
|
28
|
+
# - [Add default values for field parameters](#class-graphql-schema-field-field-parameter-default-values)
|
|
29
|
+
#
|
|
30
|
+
# ## Field Names
|
|
31
|
+
#
|
|
32
|
+
# A field's name is provided as the first argument or as the `name:` option:
|
|
33
|
+
#
|
|
34
|
+
# ```ruby
|
|
35
|
+
# field :team_captain, ...
|
|
36
|
+
# # or:
|
|
37
|
+
# field ..., name: :team_captain
|
|
38
|
+
# ```
|
|
39
|
+
#
|
|
40
|
+
# Under the hood, GraphQL-Ruby **camelizes** field names, so `field :team_captain, ...` would be `{ teamCaptain }` in GraphQL. You can disable this behavior by adding `camelize: false` to your field definition or to the [default field options](#class-graphql-schema-field-field-parameter-default-values).
|
|
41
|
+
#
|
|
42
|
+
# The field's name is also used as the basis of [field resolution](#class-graphql-schema-field-field-resolution).
|
|
43
|
+
#
|
|
44
|
+
# ## Field Return Type
|
|
45
|
+
#
|
|
46
|
+
# The second argument to `field(...)` is the return type. This can be:
|
|
47
|
+
#
|
|
48
|
+
# - A built-in GraphQL type (`Integer`, `Float`, `String`, `ID`, or `Boolean`)
|
|
49
|
+
# - A GraphQL type from your application
|
|
50
|
+
# - An _array_ of any of the above, which denotes a [list type](/type_definitions/lists).
|
|
51
|
+
#
|
|
52
|
+
# [Nullability](/type_definitions/non_nulls) is expressed with the `null:` keyword:
|
|
53
|
+
#
|
|
54
|
+
# - `null: true` (default) means that the field _may_ return `nil`
|
|
55
|
+
# - `null: false` means the field is non-nullable; it may not return `nil`. If the implementation returns `nil`, GraphQL-Ruby will return an error to the client.
|
|
56
|
+
#
|
|
57
|
+
# Additionally, list types maybe nullable by adding `[..., null: true]` to the definition.
|
|
58
|
+
#
|
|
59
|
+
# Here are some examples:
|
|
60
|
+
#
|
|
61
|
+
# ```ruby
|
|
62
|
+
# field :name, String # `String`, may return a `String` or `nil`
|
|
63
|
+
# field :id, ID, null: false # `ID!`, always returns an `ID`, never `nil`
|
|
64
|
+
# field :teammates, [Types::User], null: false # `[User!]!`, always returns a list containing `User`s
|
|
65
|
+
# field :scores, [Integer, null: true] # `[Int]`, may return a list or `nil`, the list may contain a mix of `Integer`s and `nil`s
|
|
66
|
+
# ```
|
|
67
|
+
#
|
|
68
|
+
# ## Field Documentation
|
|
69
|
+
#
|
|
70
|
+
# Fields may be documented with a __description__, __comment__ and may be __deprecated__.
|
|
71
|
+
#
|
|
72
|
+
# __Descriptions__ can be added with the `field(...)` method as a positional argument, a keyword argument, or inside the block:
|
|
73
|
+
#
|
|
74
|
+
# ```ruby
|
|
75
|
+
# # 3rd positional argument
|
|
76
|
+
# field :name, String, "The name of this thing", null: false
|
|
77
|
+
#
|
|
78
|
+
# # `description:` keyword
|
|
79
|
+
# field :name, String, null: false,
|
|
80
|
+
# description: "The name of this thing"
|
|
81
|
+
#
|
|
82
|
+
# # inside the block
|
|
83
|
+
# field :name, String, null: false do
|
|
84
|
+
# description "The name of this thing"
|
|
85
|
+
# end
|
|
86
|
+
# ```
|
|
87
|
+
#
|
|
88
|
+
# __Comments__ can be added with the `field(...)` method as a keyword argument, or inside the block:
|
|
89
|
+
# ```ruby
|
|
90
|
+
# # `comment:` keyword
|
|
91
|
+
# field :name, String, null: false, comment: "Rename to full name"
|
|
92
|
+
#
|
|
93
|
+
# # inside the block
|
|
94
|
+
# field :name, String, null: false do
|
|
95
|
+
# comment "Rename to full name"
|
|
96
|
+
# end
|
|
97
|
+
# ```
|
|
98
|
+
#
|
|
99
|
+
# Generates field name with comment above "Rename to full name" above.
|
|
100
|
+
#
|
|
101
|
+
# ```graphql
|
|
102
|
+
# type Foo {
|
|
103
|
+
# # Rename to full name
|
|
104
|
+
# name: String!
|
|
105
|
+
# }
|
|
106
|
+
# ```
|
|
107
|
+
#
|
|
108
|
+
# __Deprecated__ fields can be marked by adding a `deprecation_reason:` keyword argument:
|
|
109
|
+
#
|
|
110
|
+
# ```ruby
|
|
111
|
+
# field :email, String,
|
|
112
|
+
# deprecation_reason: "Users may have multiple emails, use `User.emails` instead."
|
|
113
|
+
# ```
|
|
114
|
+
#
|
|
115
|
+
# Fields with a `deprecation_reason:` will appear as "deprecated" in GraphiQL.
|
|
116
|
+
#
|
|
117
|
+
# ## Field Resolution
|
|
118
|
+
#
|
|
119
|
+
# In general, fields return Ruby values corresponding to their GraphQL return types. For example, a field with the return type `String` should return a Ruby string, and a field with the return type `[User!]!` should return a Ruby array with zero or more `User` objects in it.
|
|
120
|
+
#
|
|
121
|
+
# By default, fields return values by:
|
|
122
|
+
#
|
|
123
|
+
# - Trying to call a method on the underlying object; _OR_
|
|
124
|
+
# - If the underlying object is a `Hash`, lookup a key in that hash.
|
|
125
|
+
# - An optional `:fallback_value` can be supplied that will be used if the above fail.
|
|
126
|
+
#
|
|
127
|
+
# The method name or hash key corresponds to the field name, so in this example:
|
|
128
|
+
#
|
|
129
|
+
# ```ruby
|
|
130
|
+
# field :top_score, Integer, null: false
|
|
131
|
+
# ```
|
|
132
|
+
#
|
|
133
|
+
# The default behavior is to look for a `#top_score` method, or lookup a `Hash` key, `:top_score` (symbol) or `"top_score"` (string).
|
|
134
|
+
#
|
|
135
|
+
# You can override the method name with the `method:` keyword, or override the hash key(s) with the `hash_key:` or `dig:` keyword, for example:
|
|
136
|
+
#
|
|
137
|
+
# ```ruby
|
|
138
|
+
# # Use the `#best_score` method to resolve this field
|
|
139
|
+
# field :top_score, Integer, null: false,
|
|
140
|
+
# method: :best_score
|
|
141
|
+
#
|
|
142
|
+
# # Lookup `hash["allPlayers"]` to resolve this field
|
|
143
|
+
# field :players, [User], null: false,
|
|
144
|
+
# hash_key: "allPlayers"
|
|
145
|
+
#
|
|
146
|
+
# # Use the `#dig` method on the hash with `:nested` and `:movies` keys
|
|
147
|
+
# field :movies, [Movie], null: false,
|
|
148
|
+
# dig: [:nested, :movies]
|
|
149
|
+
# ```
|
|
150
|
+
#
|
|
151
|
+
# To pass-through the underlying object without calling a method on it, you can use `method: :itself`:
|
|
152
|
+
#
|
|
153
|
+
# ```ruby
|
|
154
|
+
# field :player, User, null: false,
|
|
155
|
+
# method: :itself
|
|
156
|
+
# ```
|
|
157
|
+
#
|
|
158
|
+
# This is equivalent to:
|
|
159
|
+
#
|
|
160
|
+
# ```ruby
|
|
161
|
+
# field :player, User, null: false
|
|
162
|
+
#
|
|
163
|
+
# def player
|
|
164
|
+
# object
|
|
165
|
+
# end
|
|
166
|
+
# ```
|
|
167
|
+
#
|
|
168
|
+
# If you don't want to delegate to the underlying object, you can define a method for each field:
|
|
169
|
+
#
|
|
170
|
+
# ```ruby
|
|
171
|
+
# # Use the custom method below to resolve this field
|
|
172
|
+
# field :total_games_played, Integer, null: false
|
|
173
|
+
#
|
|
174
|
+
# def total_games_played
|
|
175
|
+
# object.games.count
|
|
176
|
+
# end
|
|
177
|
+
# ```
|
|
178
|
+
#
|
|
179
|
+
# Inside the method, you can access some helper methods:
|
|
180
|
+
#
|
|
181
|
+
# - `object` is the underlying application object (formerly `obj` to resolve functions)
|
|
182
|
+
# - `context` is the query context (passed as `context:` when executing queries, formerly `ctx` to resolve functions)
|
|
183
|
+
#
|
|
184
|
+
# Additionally, when you define arguments (see below), they're passed to the method definition, for example:
|
|
185
|
+
#
|
|
186
|
+
# ```ruby
|
|
187
|
+
# # Call the custom method with incoming arguments
|
|
188
|
+
# field :current_winning_streak, Integer, null: false do
|
|
189
|
+
# argument :include_ties, Boolean, required: false, default_value: false
|
|
190
|
+
# end
|
|
191
|
+
#
|
|
192
|
+
# def current_winning_streak(include_ties:)
|
|
193
|
+
# # Business logic goes here
|
|
194
|
+
# end
|
|
195
|
+
# ```
|
|
196
|
+
#
|
|
197
|
+
# As the examples above show, by default the custom method name must match the field name. If you want to use a different custom method, the `resolver_method` option is available:
|
|
198
|
+
#
|
|
199
|
+
# ```ruby
|
|
200
|
+
# # Use the custom method with a non-default name below to resolve this field
|
|
201
|
+
# field :total_games_played, Integer, null: false, resolver_method: :games_played
|
|
202
|
+
#
|
|
203
|
+
# def games_played
|
|
204
|
+
# object.games.count
|
|
205
|
+
# end
|
|
206
|
+
# ```
|
|
207
|
+
#
|
|
208
|
+
# `resolver_method` has two main use cases:
|
|
209
|
+
#
|
|
210
|
+
# 1. resolver re-use between multiple fields
|
|
211
|
+
# 2. dealing with method conflicts (specifically if you have fields named `context` or `object`)
|
|
212
|
+
#
|
|
213
|
+
# Note that `resolver_method` _cannot_ be used in combination with `method` or `hash_key`.
|
|
214
|
+
#
|
|
215
|
+
# ## Field Arguments
|
|
216
|
+
#
|
|
217
|
+
# _Arguments_ allow fields to take input to their resolution. For example:
|
|
218
|
+
#
|
|
219
|
+
# - A `search()` field may take a `term:` argument, which is the query to use for searching, eg `search(term: "GraphQL")`
|
|
220
|
+
# - A `user()` field may take an `id:` argument, which specifies which user to find, eg `user(id: 1)`
|
|
221
|
+
# - An `attachments()` field may take a `type:` argument, which filters the result by file type, eg `attachments(type: PHOTO)`
|
|
222
|
+
#
|
|
223
|
+
# Read more in the [Arguments guide](/fields/arguments)
|
|
224
|
+
#
|
|
225
|
+
# ## Extra Field Metadata
|
|
226
|
+
#
|
|
227
|
+
# Inside a field method, you can access some low-level objects from the GraphQL-Ruby runtime. Be warned, these APIs are subject to change, so check the changelog when updating.
|
|
228
|
+
#
|
|
229
|
+
# A few `extras` are available:
|
|
230
|
+
#
|
|
231
|
+
# - `ast_node`
|
|
232
|
+
# - `graphql_name` (the field's name)
|
|
233
|
+
# - `owner` (the type that this field belongs to)
|
|
234
|
+
# - `lookahead` (see [Lookahead](/queries/lookahead))
|
|
235
|
+
# - `execution_errors`, whose `#add(err_or_msg)` method should be used for adding errors
|
|
236
|
+
# - `argument_details` (Interpreter only), an instance of [GraphQL::Execution::Interpreter::Arguments](rdoc-ref:GraphQL::Execution::Interpreter::Arguments) with argument metadata
|
|
237
|
+
# - `parent` (the previous `object` in the query)
|
|
238
|
+
# - Custom extras, see below
|
|
239
|
+
#
|
|
240
|
+
# To inject them into your field method, first, add the `extras:` option to the field definition:
|
|
241
|
+
#
|
|
242
|
+
# ```ruby
|
|
243
|
+
# field :my_field, String, null: false, extras: [:ast_node]
|
|
244
|
+
# ```
|
|
245
|
+
#
|
|
246
|
+
# Then add `ast_node:` keyword to the method signature:
|
|
247
|
+
#
|
|
248
|
+
# ```ruby
|
|
249
|
+
# def my_field(ast_node:)
|
|
250
|
+
# # ...
|
|
251
|
+
# end
|
|
252
|
+
# ```
|
|
253
|
+
#
|
|
254
|
+
# At runtime, the requested runtime object will be passed to the field.
|
|
255
|
+
#
|
|
256
|
+
# __Custom extras__ are also possible. Any method on your field class can be passed to `extras: [...]`, and the value will be injected into the method. For example, `extras: [:owner]` will inject the object type who owns the field. Any new methods on your custom field class may be used, too.
|
|
257
|
+
#
|
|
258
|
+
# ## Field Parameter Default Values
|
|
259
|
+
#
|
|
260
|
+
# The field method requires you to pass `null:` keyword argument to determine whether the field is nullable or not. For another field you may want to override `camelize`, which is `true` by default. You can override this behavior by adding a custom field with overwritten `camelize` option, which is `true` by default.
|
|
261
|
+
#
|
|
262
|
+
# ```ruby
|
|
263
|
+
# class CustomField < GraphQL::Schema::Field
|
|
264
|
+
# # Add `null: false` and `camelize: false` which provide default values
|
|
265
|
+
# # in case the caller doesn't pass anything for those arguments.
|
|
266
|
+
# # **kwargs is a catch-all that will get everything else
|
|
267
|
+
# def initialize(*args, null: false, camelize: false, **kwargs, &block)
|
|
268
|
+
# # Then, call super _without_ any args, where Ruby will take
|
|
269
|
+
# # _all_ the args originally passed to this method and pass it to the super method.
|
|
270
|
+
# super
|
|
271
|
+
# end
|
|
272
|
+
# end
|
|
273
|
+
# ```
|
|
274
|
+
#
|
|
275
|
+
# To use `CustomField` in your Objects and Interfaces, you'll need to register it as a `field_class` on those classes. See [Customizing Fields](https://graphql-ruby.org/type_definitions/extensions#customizing-fields) for more information on how to do so.
|
|
276
|
+
#
|
|
7
277
|
class Field
|
|
8
278
|
include GraphQL::Schema::Member::HasArguments
|
|
9
279
|
include GraphQL::Schema::Member::HasArguments::FieldConfigured
|
|
@@ -18,22 +288,33 @@ module GraphQL
|
|
|
18
288
|
|
|
19
289
|
class FieldImplementationFailed < GraphQL::Error; end
|
|
20
290
|
|
|
21
|
-
#
|
|
291
|
+
# **Returns**
|
|
292
|
+
#
|
|
293
|
+
# - `String` — the GraphQL name for this field, camelized unless `camelize: false` is provided
|
|
22
294
|
attr_reader :name
|
|
23
295
|
alias :graphql_name :name
|
|
24
296
|
|
|
25
297
|
attr_writer :description
|
|
26
298
|
|
|
27
|
-
#
|
|
299
|
+
# **Returns**
|
|
300
|
+
#
|
|
301
|
+
# - `Symbol` — Method or hash key on the underlying object to look up
|
|
28
302
|
attr_reader :method_sym
|
|
29
303
|
|
|
30
|
-
#
|
|
304
|
+
# **Returns**
|
|
305
|
+
#
|
|
306
|
+
# - `String` — Method or hash key on the underlying object to look up
|
|
31
307
|
attr_reader :method_str
|
|
32
308
|
|
|
33
309
|
attr_reader :hash_key
|
|
34
310
|
attr_reader :dig_keys
|
|
35
311
|
|
|
36
|
-
#
|
|
312
|
+
# **Returns**
|
|
313
|
+
#
|
|
314
|
+
# - `Symbol` — The method on the type to look up
|
|
315
|
+
#
|
|
316
|
+
# :call-seq:
|
|
317
|
+
# resolver_method() -> Symbol
|
|
37
318
|
def resolver_method
|
|
38
319
|
if @resolver_class
|
|
39
320
|
@resolver_class.resolver_method
|
|
@@ -42,7 +323,12 @@ module GraphQL
|
|
|
42
323
|
end
|
|
43
324
|
end
|
|
44
325
|
|
|
45
|
-
#
|
|
326
|
+
# **Returns**
|
|
327
|
+
#
|
|
328
|
+
# - `String, nil`
|
|
329
|
+
#
|
|
330
|
+
# :call-seq:
|
|
331
|
+
# deprecation_reason() -> String | nil
|
|
46
332
|
def deprecation_reason
|
|
47
333
|
super || @resolver_class&.deprecation_reason
|
|
48
334
|
end
|
|
@@ -68,10 +354,17 @@ module GraphQL
|
|
|
68
354
|
end
|
|
69
355
|
end
|
|
70
356
|
|
|
71
|
-
#
|
|
357
|
+
# **Returns**
|
|
358
|
+
#
|
|
359
|
+
# - `Class` — The thing this field was defined on (type, mutation, resolver)
|
|
72
360
|
attr_accessor :owner
|
|
73
361
|
|
|
74
|
-
#
|
|
362
|
+
# **Returns**
|
|
363
|
+
#
|
|
364
|
+
# - `Class` — The GraphQL type this field belongs to. (For fields defined on mutations, it's the payload type)
|
|
365
|
+
#
|
|
366
|
+
# :call-seq:
|
|
367
|
+
# owner_type() -> Class
|
|
75
368
|
def owner_type
|
|
76
369
|
@owner_type ||= if owner.nil?
|
|
77
370
|
raise GraphQL::InvariantError, "Field #{original_name.inspect} (graphql name: #{graphql_name.inspect}) has no owner, but all fields should have an owner. How did this happen?!"
|
|
@@ -82,15 +375,27 @@ module GraphQL
|
|
|
82
375
|
end
|
|
83
376
|
end
|
|
84
377
|
|
|
85
|
-
#
|
|
378
|
+
# **Returns**
|
|
379
|
+
#
|
|
380
|
+
# - `Symbol` — the original name of the field, passed in by the user
|
|
86
381
|
attr_reader :original_name
|
|
87
382
|
|
|
88
|
-
#
|
|
383
|
+
# **Returns**
|
|
384
|
+
#
|
|
385
|
+
# - `Class, nil` — The [Schema::Resolver](rdoc-ref:Schema::Resolver) this field was derived from, if there is one
|
|
386
|
+
#
|
|
387
|
+
# :call-seq:
|
|
388
|
+
# resolver() -> Class | nil
|
|
89
389
|
def resolver
|
|
90
390
|
@resolver_class
|
|
91
391
|
end
|
|
92
392
|
|
|
93
|
-
#
|
|
393
|
+
# **Returns**
|
|
394
|
+
#
|
|
395
|
+
# - `Boolean` — Is this field a predefined introspection field?
|
|
396
|
+
#
|
|
397
|
+
# :call-seq:
|
|
398
|
+
# introspection?() -> bool
|
|
94
399
|
def introspection?
|
|
95
400
|
@introspection
|
|
96
401
|
end
|
|
@@ -101,17 +406,30 @@ module GraphQL
|
|
|
101
406
|
|
|
102
407
|
alias :mutation :resolver
|
|
103
408
|
|
|
104
|
-
#
|
|
409
|
+
# **Returns**
|
|
410
|
+
#
|
|
411
|
+
# - `Boolean` — Apply tracing to this field? (Default: skip scalars, this is the override value)
|
|
105
412
|
attr_reader :trace
|
|
106
413
|
|
|
107
|
-
#
|
|
414
|
+
# **Returns**
|
|
415
|
+
#
|
|
416
|
+
# - `String, nil`
|
|
417
|
+
#
|
|
418
|
+
# :call-seq:
|
|
419
|
+
# subscription_scope() -> String | nil
|
|
108
420
|
def subscription_scope
|
|
109
421
|
@subscription_scope || (@resolver_class.respond_to?(:subscription_scope) ? @resolver_class.subscription_scope : nil)
|
|
110
422
|
end
|
|
111
423
|
attr_writer :subscription_scope
|
|
112
424
|
|
|
113
425
|
# Can be set with `connection: true|false` or inferred from a type name ending in `*Connection`
|
|
114
|
-
#
|
|
426
|
+
#
|
|
427
|
+
# **Returns**
|
|
428
|
+
#
|
|
429
|
+
# - `Boolean` — if true, this field will be wrapped with Relay connection behavior
|
|
430
|
+
#
|
|
431
|
+
# :call-seq:
|
|
432
|
+
# connection?() -> bool
|
|
115
433
|
def connection?
|
|
116
434
|
if @connection.nil?
|
|
117
435
|
# Provide default based on type name
|
|
@@ -134,7 +452,12 @@ module GraphQL
|
|
|
134
452
|
end
|
|
135
453
|
end
|
|
136
454
|
|
|
137
|
-
#
|
|
455
|
+
# **Returns**
|
|
456
|
+
#
|
|
457
|
+
# - `Boolean` — if true, the return type's `.scope_items` method will be applied to this field's return value
|
|
458
|
+
#
|
|
459
|
+
# :call-seq:
|
|
460
|
+
# scoped?() -> bool
|
|
138
461
|
def scoped?
|
|
139
462
|
if !@scope.nil?
|
|
140
463
|
# The default was overridden
|
|
@@ -154,14 +477,26 @@ module GraphQL
|
|
|
154
477
|
end
|
|
155
478
|
end
|
|
156
479
|
|
|
157
|
-
# This extension is applied to fields when
|
|
480
|
+
# This extension is applied to fields when [connection?](rdoc-ref:#connection?) is true.
|
|
158
481
|
#
|
|
159
482
|
# You can override it in your base field definition.
|
|
160
|
-
#
|
|
161
|
-
#
|
|
162
|
-
#
|
|
163
|
-
#
|
|
164
|
-
#
|
|
483
|
+
#
|
|
484
|
+
# **Returns**
|
|
485
|
+
#
|
|
486
|
+
# - `Class` — A [FieldExtension](rdoc-ref:FieldExtension) subclass for implementing pagination behavior.
|
|
487
|
+
#
|
|
488
|
+
# **Examples**
|
|
489
|
+
#
|
|
490
|
+
# **Example: Configuring a custom extension**
|
|
491
|
+
#
|
|
492
|
+
# ```ruby
|
|
493
|
+
# class Types::BaseField < GraphQL::Schema::Field
|
|
494
|
+
# connection_extension(MyCustomExtension)
|
|
495
|
+
# end
|
|
496
|
+
# ```
|
|
497
|
+
#
|
|
498
|
+
# :call-seq:
|
|
499
|
+
# connection_extension(new_extension_class) -> Class
|
|
165
500
|
def self.connection_extension(new_extension_class = nil)
|
|
166
501
|
if new_extension_class
|
|
167
502
|
@connection_extension = new_extension_class
|
|
@@ -170,57 +505,115 @@ module GraphQL
|
|
|
170
505
|
end
|
|
171
506
|
end
|
|
172
507
|
|
|
173
|
-
#
|
|
508
|
+
# **Returns**
|
|
509
|
+
#
|
|
510
|
+
# - `Object` — Boolean
|
|
174
511
|
attr_reader :relay_node_field
|
|
175
|
-
#
|
|
512
|
+
# **Returns**
|
|
513
|
+
#
|
|
514
|
+
# - `Object` — Boolean
|
|
176
515
|
attr_reader :relay_nodes_field
|
|
177
516
|
|
|
178
|
-
#
|
|
517
|
+
# **Returns**
|
|
518
|
+
#
|
|
519
|
+
# - `Boolean` — Should we warn if this field's name conflicts with a built-in method?
|
|
520
|
+
#
|
|
521
|
+
# :call-seq:
|
|
522
|
+
# method_conflict_warning?() -> bool
|
|
179
523
|
def method_conflict_warning?
|
|
180
524
|
@method_conflict_warning
|
|
181
525
|
end
|
|
182
526
|
|
|
183
|
-
#
|
|
184
|
-
#
|
|
185
|
-
#
|
|
186
|
-
#
|
|
187
|
-
#
|
|
188
|
-
#
|
|
189
|
-
#
|
|
190
|
-
#
|
|
191
|
-
#
|
|
192
|
-
#
|
|
193
|
-
#
|
|
194
|
-
#
|
|
195
|
-
#
|
|
196
|
-
#
|
|
197
|
-
#
|
|
198
|
-
#
|
|
199
|
-
#
|
|
200
|
-
#
|
|
201
|
-
#
|
|
202
|
-
#
|
|
203
|
-
#
|
|
204
|
-
#
|
|
205
|
-
#
|
|
206
|
-
#
|
|
207
|
-
#
|
|
208
|
-
#
|
|
209
|
-
#
|
|
210
|
-
#
|
|
211
|
-
#
|
|
212
|
-
#
|
|
213
|
-
#
|
|
214
|
-
#
|
|
215
|
-
#
|
|
216
|
-
#
|
|
217
|
-
#
|
|
218
|
-
#
|
|
219
|
-
#
|
|
220
|
-
#
|
|
221
|
-
#
|
|
222
|
-
#
|
|
223
|
-
|
|
527
|
+
# **Parameters**
|
|
528
|
+
#
|
|
529
|
+
# - `name` (`Symbol`) — The underscore-cased version of this field name (will be camelized for the GraphQL API)
|
|
530
|
+
# - `type` (`Class, GraphQL::BaseType, Array`) — The return type of this field
|
|
531
|
+
# - `owner` (`Class`) — The type that this field belongs to
|
|
532
|
+
# - `null` (`Boolean`) — (defaults to `true`) `true` if this field may return `null`, `false` if it is never `null`
|
|
533
|
+
# - `description` (`String`) — Field description
|
|
534
|
+
# - `comment` (`String`) — Field comment
|
|
535
|
+
# - `deprecation_reason` (`String`) — If present, the field is marked "deprecated" with this message
|
|
536
|
+
# - `method` (`Symbol`) — The method to call on the underlying object to resolve this field (defaults to `name`)
|
|
537
|
+
# - `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`)
|
|
538
|
+
# - `dig` (`Array<String, Symbol>`) — The nested hash keys to lookup on the underlying hash to resolve this field using dig
|
|
539
|
+
# - `resolver_method` (`Symbol`) — The method on the type to call to resolve this field (defaults to `name`)
|
|
540
|
+
# - `connection` (`Boolean`) — `true` if this field should get automagic connection behavior; default is to infer by `*Connection` in the return type name
|
|
541
|
+
# - `connection_extension` (`Class`) — The extension to add, to implement connections. If `nil`, no extension is added.
|
|
542
|
+
# - `resolve_static` (`Symbol, true, nil`) — 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`
|
|
543
|
+
# - `resolve_batch` (`Symbol, true, nil`) — Used by `Schema.execute_next` map `objects` to a same-sized Array of results. Called on the owner type class with `objects, context, **arguments`.
|
|
544
|
+
# - `resolve_each` (`Symbol, true, nil`) — Used by `Schema.execute_next` to get a value value for each item. Called on the owner type class with `object, context, **arguments`.
|
|
545
|
+
# - `resolve_legacy_instance_method` (`Symbol, true, nil`) — Used by `Schema.execute_next` to get a value value for each item. Calls an instance method on the object type class.
|
|
546
|
+
# - `dataload` (`Class, Hash`) — Shorthand for making dataloader calls
|
|
547
|
+
# - `max_page_size` (`Integer, nil`) — For connections, the maximum number of items to return from this field, or `nil` to allow unlimited results.
|
|
548
|
+
# - `default_page_size` (`Integer, nil`) — For connections, the default number of items to return from this field, or `nil` to return unlimited results.
|
|
549
|
+
# - `introspection` (`Boolean`) — If true, this field will be marked as `#introspection?` and the name may begin with `__`
|
|
550
|
+
# - `resolver_class` (`Class`) — (Private) A [Schema::Resolver](rdoc-ref:Schema::Resolver) which this field was derived from. Use `resolver:` to create a field with a resolver.
|
|
551
|
+
# - `arguments` (`{String=>GraphQL::Schema::Argument, Hash}`) — Arguments for this field (may be added in the block, also)
|
|
552
|
+
# - `camelize` (`Boolean`) — If true, the field name will be camelized when building the schema
|
|
553
|
+
# - `complexity` (`Numeric`) — When provided, set the complexity for this field
|
|
554
|
+
# - `scope` (`Boolean`) — If true, the return type's `.scope_items` method will be called on the return value
|
|
555
|
+
# - `subscription_scope` (`Symbol, String`) — A key in `context` which will be used to scope subscription payloads
|
|
556
|
+
# - `extensions` (`Array<Class, Hash<Class => Object>>`) — Named extensions to apply to this field (see also [extension](rdoc-ref:GraphQL::Schema::Field#extension))
|
|
557
|
+
# - `directives` (`Hash{Class => Hash}`) — Directives to apply to this field
|
|
558
|
+
# - `trace` (`Boolean`) — If true, a [GraphQL::Tracing](rdoc-ref:GraphQL::Tracing) tracer will measure this scalar field
|
|
559
|
+
# - `broadcastable` (`Boolean`) — Whether or not this field can be distributed in subscription broadcasts
|
|
560
|
+
# - `ast_node` (`Language::Nodes::FieldDefinition, nil`) — If this schema was parsed from definition, this AST node defined the field
|
|
561
|
+
# - `method_conflict_warning` (`Boolean`) — If false, skip the warning if this field's method conflicts with a built-in method
|
|
562
|
+
# - `validates` (`Array<Hash>`) — Configurations for validating this field
|
|
563
|
+
# - `fallback_value` (`Object`) — A fallback value if the method is not defined
|
|
564
|
+
# - `dynamic_introspection` (`Boolean`) — (Private, used by GraphQL-Ruby)
|
|
565
|
+
# - `relay_node_field` (`Boolean`) — (Private, used by GraphQL-Ruby)
|
|
566
|
+
# - `relay_nodes_field` (`Boolean`) — (Private, used by GraphQL-Ruby)
|
|
567
|
+
# - `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
|
|
568
|
+
# - `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).
|
|
569
|
+
#
|
|
570
|
+
# :call-seq:
|
|
571
|
+
# initialize(Class | GraphQL::BaseType | Array type:, Symbol name:, Class owner:, bool null:, String description:, String comment:, String deprecation_reason:, Symbol method:, Symbol | true | nil resolve_legacy_instance_method:, Symbol | true | nil resolve_static:, Symbol | true | nil resolve_each:, Symbol | true | nil resolve_batch:, String | Symbol hash_key:, Array[String | Symbol] dig:, Symbol resolver_method:, bool connection:, Integer | nil max_page_size:, Integer | nil default_page_size:, Array[:ast_node | :parent | :lookahead | :owner | :execution_errors | :graphql_name | :argument_details | Symbol] extras:, Array[Class | Hash[Class, Object]] extensions:, Class connection_extension:, Class resolver_class:, Symbol | String subscription_scope:, bool relay_node_field:, bool relay_nodes_field:, bool method_conflict_warning:, bool broadcastable:, {String=>GraphQL::Schema::Argument | Hash} arguments:, Hash[Class, Hash] directives:, Array[Hash] validates:, Object fallback_value:, bool dynamic_introspection:, bool scope:, bool introspection:, bool camelize:, bool trace:, Numeric complexity:, Class | Hash dataload:, Language::Nodes::FieldDefinition | nil ast_node:, Proc &definition_block)
|
|
572
|
+
def initialize(
|
|
573
|
+
type: nil,
|
|
574
|
+
name: nil,
|
|
575
|
+
owner: nil,
|
|
576
|
+
null: nil,
|
|
577
|
+
description: NOT_CONFIGURED,
|
|
578
|
+
comment: NOT_CONFIGURED,
|
|
579
|
+
deprecation_reason: nil,
|
|
580
|
+
method: nil,
|
|
581
|
+
resolve_legacy_instance_method: nil,
|
|
582
|
+
resolve_static: nil,
|
|
583
|
+
resolve_each: nil,
|
|
584
|
+
resolve_batch: nil,
|
|
585
|
+
hash_key: nil,
|
|
586
|
+
dig: nil,
|
|
587
|
+
resolver_method: nil,
|
|
588
|
+
connection: nil,
|
|
589
|
+
max_page_size: NOT_CONFIGURED,
|
|
590
|
+
default_page_size: NOT_CONFIGURED,
|
|
591
|
+
extras: EMPTY_ARRAY,
|
|
592
|
+
extensions: EMPTY_ARRAY,
|
|
593
|
+
connection_extension: self.class.connection_extension,
|
|
594
|
+
resolver_class: nil,
|
|
595
|
+
subscription_scope: nil,
|
|
596
|
+
relay_node_field: false,
|
|
597
|
+
relay_nodes_field: false,
|
|
598
|
+
method_conflict_warning: true,
|
|
599
|
+
broadcastable: NOT_CONFIGURED,
|
|
600
|
+
arguments: EMPTY_HASH,
|
|
601
|
+
directives: EMPTY_HASH,
|
|
602
|
+
validates: EMPTY_ARRAY,
|
|
603
|
+
fallback_value: NOT_CONFIGURED,
|
|
604
|
+
# Keywords below this line must have literal defaults (`nil`, `true`, `false`, a number or a symbol).
|
|
605
|
+
# Ruby uses a 31-bit bitmap to track which keywords with non-literal defaults were given.
|
|
606
|
+
# If one comes after the 31st keyword, Ruby allocates a Hash on every call.
|
|
607
|
+
dynamic_introspection: false,
|
|
608
|
+
scope: nil,
|
|
609
|
+
introspection: false,
|
|
610
|
+
camelize: true,
|
|
611
|
+
trace: nil,
|
|
612
|
+
complexity: nil,
|
|
613
|
+
dataload: nil,
|
|
614
|
+
ast_node: nil,
|
|
615
|
+
&definition_block
|
|
616
|
+
)
|
|
224
617
|
if name.nil?
|
|
225
618
|
raise ArgumentError, "missing first `name` argument or keyword `name:`"
|
|
226
619
|
end
|
|
@@ -232,7 +625,6 @@ module GraphQL
|
|
|
232
625
|
@original_name = name
|
|
233
626
|
name_s = -name.to_s
|
|
234
627
|
|
|
235
|
-
@underscored_name = -Member::BuildType.underscore(name_s)
|
|
236
628
|
@name = -(camelize ? Member::BuildType.camelize(name_s) : name_s)
|
|
237
629
|
NameValidator.validate!(@name)
|
|
238
630
|
@description = description
|
|
@@ -368,15 +760,16 @@ module GraphQL
|
|
|
368
760
|
end
|
|
369
761
|
end
|
|
370
762
|
|
|
371
|
-
#
|
|
372
|
-
attr_reader :execution_mode_key, :execution_mode
|
|
763
|
+
attr_reader :execution_mode_key, :execution_mode # :nodoc:
|
|
373
764
|
|
|
374
765
|
# Calls the definition block, if one was given.
|
|
375
766
|
# This is deferred so that references to the return type
|
|
376
767
|
# can be lazily evaluated, reducing Rails boot time.
|
|
377
|
-
#
|
|
378
|
-
#
|
|
379
|
-
|
|
768
|
+
#
|
|
769
|
+
# **Returns**
|
|
770
|
+
#
|
|
771
|
+
# - `self`
|
|
772
|
+
def ensure_loaded # :nodoc:
|
|
380
773
|
if @definition_block
|
|
381
774
|
if @definition_block.arity == 1
|
|
382
775
|
@definition_block.call(self)
|
|
@@ -393,8 +786,14 @@ module GraphQL
|
|
|
393
786
|
attr_accessor :dynamic_introspection
|
|
394
787
|
|
|
395
788
|
# If true, subscription updates with this field can be shared between viewers
|
|
396
|
-
#
|
|
397
|
-
#
|
|
789
|
+
# See `GraphQL::Subscriptions::BroadcastAnalyzer`.
|
|
790
|
+
#
|
|
791
|
+
# **Returns**
|
|
792
|
+
#
|
|
793
|
+
# - `Boolean, nil`
|
|
794
|
+
#
|
|
795
|
+
# :call-seq:
|
|
796
|
+
# broadcastable?() -> bool | nil
|
|
398
797
|
def broadcastable?
|
|
399
798
|
if !NOT_CONFIGURED.equal?(@broadcastable)
|
|
400
799
|
@broadcastable
|
|
@@ -405,8 +804,16 @@ module GraphQL
|
|
|
405
804
|
end
|
|
406
805
|
end
|
|
407
806
|
|
|
408
|
-
#
|
|
409
|
-
#
|
|
807
|
+
# **Parameters**
|
|
808
|
+
#
|
|
809
|
+
# - `text` (`String`)
|
|
810
|
+
#
|
|
811
|
+
# **Returns**
|
|
812
|
+
#
|
|
813
|
+
# - `String`
|
|
814
|
+
#
|
|
815
|
+
# :call-seq:
|
|
816
|
+
# description(String text) -> String
|
|
410
817
|
def description(text = nil)
|
|
411
818
|
if text
|
|
412
819
|
@description = text
|
|
@@ -419,8 +826,16 @@ module GraphQL
|
|
|
419
826
|
end
|
|
420
827
|
end
|
|
421
828
|
|
|
422
|
-
#
|
|
423
|
-
#
|
|
829
|
+
# **Parameters**
|
|
830
|
+
#
|
|
831
|
+
# - `text` (`String`)
|
|
832
|
+
#
|
|
833
|
+
# **Returns**
|
|
834
|
+
#
|
|
835
|
+
# - `String, nil`
|
|
836
|
+
#
|
|
837
|
+
# :call-seq:
|
|
838
|
+
# comment(String text) -> String | nil
|
|
424
839
|
def comment(text = nil)
|
|
425
840
|
if text
|
|
426
841
|
@comment = text
|
|
@@ -437,17 +852,36 @@ module GraphQL
|
|
|
437
852
|
# or add new classes/options to be initialized on this field.
|
|
438
853
|
# Extensions are executed in the order they are added.
|
|
439
854
|
#
|
|
440
|
-
#
|
|
441
|
-
#
|
|
855
|
+
# **Examples**
|
|
856
|
+
#
|
|
857
|
+
# **Example: adding an extension**
|
|
858
|
+
#
|
|
859
|
+
# ```ruby
|
|
860
|
+
# extensions([MyExtensionClass])
|
|
861
|
+
# ```
|
|
862
|
+
#
|
|
863
|
+
# **Example: adding multiple extensions**
|
|
442
864
|
#
|
|
443
|
-
#
|
|
444
|
-
#
|
|
865
|
+
# ```ruby
|
|
866
|
+
# extensions([MyExtensionClass, AnotherExtensionClass])
|
|
867
|
+
# ```
|
|
445
868
|
#
|
|
446
|
-
#
|
|
447
|
-
# extensions([MyExtensionClass, { AnotherExtensionClass => { filter: true } }])
|
|
869
|
+
# **Example: adding an extension with options**
|
|
448
870
|
#
|
|
449
|
-
#
|
|
450
|
-
#
|
|
871
|
+
# ```ruby
|
|
872
|
+
# extensions([MyExtensionClass, { AnotherExtensionClass => { filter: true } }])
|
|
873
|
+
# ```
|
|
874
|
+
#
|
|
875
|
+
# **Parameters**
|
|
876
|
+
#
|
|
877
|
+
# - `extensions` (`Array<Class, Hash<Class => Hash>>`) — Add extensions to this field. For hash elements, only the first key/value is used.
|
|
878
|
+
#
|
|
879
|
+
# **Returns**
|
|
880
|
+
#
|
|
881
|
+
# - `Array<GraphQL::Schema::FieldExtension>` — extensions to apply to this field
|
|
882
|
+
#
|
|
883
|
+
# :call-seq:
|
|
884
|
+
# extensions(new_extensions) -> Array[GraphQL::Schema::FieldExtension]
|
|
451
885
|
def extensions(new_extensions = nil)
|
|
452
886
|
if new_extensions
|
|
453
887
|
new_extensions.each do |extension_config|
|
|
@@ -464,15 +898,31 @@ module GraphQL
|
|
|
464
898
|
|
|
465
899
|
# Add `extension` to this field, initialized with `options` if provided.
|
|
466
900
|
#
|
|
467
|
-
#
|
|
468
|
-
#
|
|
901
|
+
# **Examples**
|
|
902
|
+
#
|
|
903
|
+
# **Example: adding an extension**
|
|
469
904
|
#
|
|
470
|
-
#
|
|
471
|
-
#
|
|
905
|
+
# ```ruby
|
|
906
|
+
# extension(MyExtensionClass)
|
|
907
|
+
# ```
|
|
472
908
|
#
|
|
473
|
-
#
|
|
474
|
-
#
|
|
475
|
-
#
|
|
909
|
+
# **Example: adding an extension with options**
|
|
910
|
+
#
|
|
911
|
+
# ```ruby
|
|
912
|
+
# extension(MyExtensionClass, filter: true)
|
|
913
|
+
# ```
|
|
914
|
+
#
|
|
915
|
+
# **Parameters**
|
|
916
|
+
#
|
|
917
|
+
# - `extension_class` (`Class`) — subclass of [Schema::FieldExtension](rdoc-ref:Schema::FieldExtension)
|
|
918
|
+
# - `options` (`Hash`) — if provided, given as `options:` when initializing `extension`.
|
|
919
|
+
#
|
|
920
|
+
# **Returns**
|
|
921
|
+
#
|
|
922
|
+
# - `void`
|
|
923
|
+
#
|
|
924
|
+
# :call-seq:
|
|
925
|
+
# extension(Class extension_class, Hash **options) -> void
|
|
476
926
|
def extension(extension_class, **options)
|
|
477
927
|
extension_inst = extension_class.new(field: self, options: options)
|
|
478
928
|
if @extensions.frozen?
|
|
@@ -488,8 +938,16 @@ module GraphQL
|
|
|
488
938
|
# Read extras (as symbols) from this field,
|
|
489
939
|
# or add new extras to be opted into by this field's resolver.
|
|
490
940
|
#
|
|
491
|
-
#
|
|
492
|
-
#
|
|
941
|
+
# **Parameters**
|
|
942
|
+
#
|
|
943
|
+
# - `new_extras` (`Array<Symbol>`) — Add extras to this field
|
|
944
|
+
#
|
|
945
|
+
# **Returns**
|
|
946
|
+
#
|
|
947
|
+
# - `Array<Symbol>`
|
|
948
|
+
#
|
|
949
|
+
# :call-seq:
|
|
950
|
+
# extras(Array[Symbol] new_extras) -> Array[Symbol]
|
|
493
951
|
def extras(new_extras = nil)
|
|
494
952
|
if new_extras.nil?
|
|
495
953
|
# Read the value
|
|
@@ -536,14 +994,22 @@ module GraphQL
|
|
|
536
994
|
else
|
|
537
995
|
metadata_complexity = 0
|
|
538
996
|
lookahead = GraphQL::Execution::Lookahead.new(query: query, field: self, ast_nodes: nodes, owner_type: owner)
|
|
997
|
+
# `QueryComplexity` doesn't add skipped introspection fields to `child_complexity`,
|
|
998
|
+
# so they must not be subtracted from it here, either.
|
|
999
|
+
count_introspection_fields = query.schema.max_complexity_count_introspection_fields
|
|
539
1000
|
|
|
540
1001
|
lookahead.selections.each do |next_lookahead|
|
|
1002
|
+
next if !count_introspection_fields && next_lookahead.field.introspection?
|
|
541
1003
|
# this includes `pageInfo`, `nodes` and `edges` and any custom fields
|
|
542
1004
|
# TODO this doesn't support procs yet -- unlikely to need it.
|
|
543
1005
|
metadata_complexity += next_lookahead.field.complexity
|
|
544
1006
|
if next_lookahead.name != :nodes && next_lookahead.name != :edges
|
|
545
1007
|
# subfields, eg, for pageInfo -- assumes no subselections
|
|
546
|
-
|
|
1008
|
+
if count_introspection_fields
|
|
1009
|
+
metadata_complexity += next_lookahead.selections.size
|
|
1010
|
+
else
|
|
1011
|
+
metadata_complexity += next_lookahead.selections.count { |s| !s.field.introspection? }
|
|
1012
|
+
end
|
|
547
1013
|
end
|
|
548
1014
|
end
|
|
549
1015
|
|
|
@@ -582,12 +1048,22 @@ module GraphQL
|
|
|
582
1048
|
end
|
|
583
1049
|
end
|
|
584
1050
|
|
|
585
|
-
#
|
|
1051
|
+
# **Returns**
|
|
1052
|
+
#
|
|
1053
|
+
# - `Boolean` — True if this field's [max page size](rdoc-ref:#max_page_size) should override the schema default.
|
|
1054
|
+
#
|
|
1055
|
+
# :call-seq:
|
|
1056
|
+
# has_max_page_size?() -> bool
|
|
586
1057
|
def has_max_page_size?
|
|
587
1058
|
!NOT_CONFIGURED.equal?(@max_page_size) || (@resolver_class && @resolver_class.has_max_page_size?)
|
|
588
1059
|
end
|
|
589
1060
|
|
|
590
|
-
#
|
|
1061
|
+
# **Returns**
|
|
1062
|
+
#
|
|
1063
|
+
# - `Integer, nil` — Applied to connections if [has max page size?](rdoc-ref:#has_max_page_size?)
|
|
1064
|
+
#
|
|
1065
|
+
# :call-seq:
|
|
1066
|
+
# max_page_size() -> Integer | nil
|
|
591
1067
|
def max_page_size
|
|
592
1068
|
if !NOT_CONFIGURED.equal?(@max_page_size)
|
|
593
1069
|
@max_page_size
|
|
@@ -598,12 +1074,22 @@ module GraphQL
|
|
|
598
1074
|
end
|
|
599
1075
|
end
|
|
600
1076
|
|
|
601
|
-
#
|
|
1077
|
+
# **Returns**
|
|
1078
|
+
#
|
|
1079
|
+
# - `Boolean` — True if this field's [default page size](rdoc-ref:#default_page_size) should override the schema default.
|
|
1080
|
+
#
|
|
1081
|
+
# :call-seq:
|
|
1082
|
+
# has_default_page_size?() -> bool
|
|
602
1083
|
def has_default_page_size?
|
|
603
1084
|
!NOT_CONFIGURED.equal?(@default_page_size) || (@resolver_class && @resolver_class.has_default_page_size?)
|
|
604
1085
|
end
|
|
605
1086
|
|
|
606
|
-
#
|
|
1087
|
+
# **Returns**
|
|
1088
|
+
#
|
|
1089
|
+
# - `Integer, nil` — Applied to connections if [has default page size?](rdoc-ref:#has_default_page_size?)
|
|
1090
|
+
#
|
|
1091
|
+
# :call-seq:
|
|
1092
|
+
# default_page_size() -> Integer | nil
|
|
607
1093
|
def default_page_size
|
|
608
1094
|
if !NOT_CONFIGURED.equal?(@default_page_size)
|
|
609
1095
|
@default_page_size
|
|
@@ -628,8 +1114,17 @@ module GraphQL
|
|
|
628
1114
|
# Get or set the return type of this field.
|
|
629
1115
|
#
|
|
630
1116
|
# It may return nil if no type was configured or if the given definition block wasn't called yet.
|
|
631
|
-
#
|
|
632
|
-
#
|
|
1117
|
+
#
|
|
1118
|
+
# **Parameters**
|
|
1119
|
+
#
|
|
1120
|
+
# - `new_type` (`Module, GraphQL::Schema::NonNull, GraphQL::Schema::List`) — A GraphQL return type
|
|
1121
|
+
#
|
|
1122
|
+
# **Returns**
|
|
1123
|
+
#
|
|
1124
|
+
# - `Module, GraphQL::Schema::NonNull, GraphQL::Schema::List, nil` — the configured type for this field
|
|
1125
|
+
#
|
|
1126
|
+
# :call-seq:
|
|
1127
|
+
# type(Module | GraphQL::Schema::NonNull | GraphQL::Schema::List new_type) -> Module | GraphQL::Schema::NonNull | GraphQL::Schema::List | nil
|
|
633
1128
|
def type(new_type = NOT_CONFIGURED)
|
|
634
1129
|
if NOT_CONFIGURED.equal?(new_type)
|
|
635
1130
|
if @resolver_class
|
|
@@ -716,15 +1211,21 @@ module GraphQL
|
|
|
716
1211
|
|
|
717
1212
|
# This method is called by the interpreter for each field.
|
|
718
1213
|
# You can extend it in your base field classes.
|
|
719
|
-
#
|
|
720
|
-
#
|
|
721
|
-
#
|
|
1214
|
+
#
|
|
1215
|
+
# **Parameters**
|
|
1216
|
+
#
|
|
1217
|
+
# - `object` (`GraphQL::Schema::Object`) — An instance of some type class, wrapping an application object
|
|
1218
|
+
# - `args` (`Hash`) — A symbol-keyed hash of Ruby keyword arguments. (Empty if no args)
|
|
1219
|
+
# - `ctx` (`GraphQL::Query::Context`)
|
|
1220
|
+
#
|
|
1221
|
+
# :call-seq:
|
|
1222
|
+
# resolve(GraphQL::Schema::Object object, Hash args, query_ctx)
|
|
722
1223
|
def resolve(object, args, query_ctx)
|
|
723
1224
|
# Unwrap the GraphQL object to get the application object.
|
|
724
1225
|
application_object = object.object
|
|
725
|
-
method_receiver = nil
|
|
726
|
-
method_to_call = nil
|
|
727
|
-
method_args = nil
|
|
1226
|
+
method_receiver = nil #: untyped
|
|
1227
|
+
method_to_call = nil #: untyped
|
|
1228
|
+
method_args = nil #: untyped
|
|
728
1229
|
|
|
729
1230
|
@own_validators && Schema::Validator.validate!(validators, application_object, query_ctx, args)
|
|
730
1231
|
|
|
@@ -824,7 +1325,12 @@ module GraphQL
|
|
|
824
1325
|
err
|
|
825
1326
|
end
|
|
826
1327
|
|
|
827
|
-
#
|
|
1328
|
+
# **Parameters**
|
|
1329
|
+
#
|
|
1330
|
+
# - `ctx` (`GraphQL::Query::Context`)
|
|
1331
|
+
#
|
|
1332
|
+
# :call-seq:
|
|
1333
|
+
# fetch_extra(extra_name, GraphQL::Query::Context ctx)
|
|
828
1334
|
def fetch_extra(extra_name, ctx)
|
|
829
1335
|
if extra_name != :path && extra_name != :ast_node && respond_to?(extra_name)
|
|
830
1336
|
self.public_send(extra_name)
|
|
@@ -841,7 +1347,7 @@ module GraphQL
|
|
|
841
1347
|
method_defn = receiver.method(method_name)
|
|
842
1348
|
unsatisfied_ruby_kwargs = ruby_kwargs.dup
|
|
843
1349
|
unsatisfied_method_params = []
|
|
844
|
-
encountered_keyrest = false
|
|
1350
|
+
encountered_keyrest = false #: bool
|
|
845
1351
|
method_defn.parameters.each do |(param_type, param_name)|
|
|
846
1352
|
case param_type
|
|
847
1353
|
when :key
|
|
@@ -890,7 +1396,13 @@ ERR
|
|
|
890
1396
|
|
|
891
1397
|
# Wrap execution with hooks.
|
|
892
1398
|
# Written iteratively to avoid big stack traces.
|
|
893
|
-
#
|
|
1399
|
+
#
|
|
1400
|
+
# **Returns**
|
|
1401
|
+
#
|
|
1402
|
+
# - `Object` — Whatever the
|
|
1403
|
+
#
|
|
1404
|
+
# :call-seq:
|
|
1405
|
+
# with_extensions(obj, args, ctx) -> Object
|
|
894
1406
|
def with_extensions(obj, args, ctx)
|
|
895
1407
|
if @extensions.empty?
|
|
896
1408
|
yield(obj, args)
|