graphql 2.6.9 → 2.6.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rdoc_options +4 -0
- data/lib/generators/graphql/core.rb +1 -0
- data/lib/generators/graphql/detailed_trace_generator.rb +1 -0
- data/lib/generators/graphql/enum_generator.rb +1 -0
- data/lib/generators/graphql/field_extractor.rb +1 -0
- data/lib/generators/graphql/input_generator.rb +1 -0
- data/lib/generators/graphql/install/mutation_root_generator.rb +1 -0
- data/lib/generators/graphql/install_generator.rb +1 -0
- data/lib/generators/graphql/interface_generator.rb +1 -0
- data/lib/generators/graphql/loader_generator.rb +8 -2
- data/lib/generators/graphql/mutation_create_generator.rb +8 -2
- data/lib/generators/graphql/mutation_delete_generator.rb +8 -2
- data/lib/generators/graphql/mutation_generator.rb +8 -2
- data/lib/generators/graphql/mutation_update_generator.rb +8 -2
- data/lib/generators/graphql/object_generator.rb +1 -0
- data/lib/generators/graphql/orm_mutations_base.rb +8 -2
- data/lib/generators/graphql/relay.rb +1 -0
- data/lib/generators/graphql/relay_generator.rb +1 -0
- data/lib/generators/graphql/scalar_generator.rb +1 -0
- data/lib/generators/graphql/type_generator.rb +38 -8
- data/lib/generators/graphql/union_generator.rb +1 -0
- data/lib/graphql/analysis/analyzer.rb +35 -9
- data/lib/graphql/analysis/field_usage.rb +1 -0
- data/lib/graphql/analysis/max_query_complexity.rb +3 -2
- data/lib/graphql/analysis/max_query_depth.rb +1 -0
- data/lib/graphql/analysis/query_complexity.rb +57 -20
- data/lib/graphql/analysis/query_depth.rb +17 -12
- data/lib/graphql/analysis/visitor.rb +79 -16
- data/lib/graphql/analysis.rb +23 -6
- data/lib/graphql/analysis_error.rb +1 -0
- data/lib/graphql/autoload.rb +30 -7
- data/lib/graphql/backtrace/table.rb +21 -5
- data/lib/graphql/backtrace/traced_error.rb +8 -3
- data/lib/graphql/backtrace.rb +14 -9
- data/lib/graphql/coercion_error.rb +1 -0
- data/lib/graphql/current.rb +44 -19
- data/lib/graphql/dashboard/application_controller.rb +1 -0
- data/lib/graphql/dashboard/detailed_traces.rb +1 -0
- data/lib/graphql/dashboard/installable.rb +1 -0
- data/lib/graphql/dashboard/landings_controller.rb +1 -0
- data/lib/graphql/dashboard/limiters.rb +1 -0
- data/lib/graphql/dashboard/operation_store.rb +1 -0
- data/lib/graphql/dashboard/statics_controller.rb +1 -0
- data/lib/graphql/dashboard/subscriptions.rb +1 -0
- data/lib/graphql/dashboard.rb +36 -22
- data/lib/graphql/dataloader/active_record_association_source.rb +1 -0
- data/lib/graphql/dataloader/active_record_source.rb +1 -0
- data/lib/graphql/dataloader/async_dataloader.rb +45 -16
- data/lib/graphql/dataloader/null_dataloader.rb +4 -3
- data/lib/graphql/dataloader/request.rb +8 -2
- data/lib/graphql/dataloader/request_all.rb +8 -2
- data/lib/graphql/dataloader/source.rb +127 -35
- data/lib/graphql/dataloader.rb +98 -44
- data/lib/graphql/date_encoding_error.rb +2 -1
- data/lib/graphql/dig.rb +12 -3
- data/lib/graphql/duration_encoding_error.rb +2 -1
- data/lib/graphql/execution/directive_checks.rb +8 -3
- data/lib/graphql/execution/errors.rb +20 -6
- data/lib/graphql/execution/field_resolve_step.rb +288 -168
- data/lib/graphql/execution/finalize.rb +12 -6
- data/lib/graphql/execution/input_values.rb +5 -2
- data/lib/graphql/execution/interpreter/argument_value.rb +17 -5
- data/lib/graphql/execution/interpreter/arguments.rb +24 -9
- data/lib/graphql/execution/interpreter/arguments_cache.rb +2 -1
- data/lib/graphql/execution/interpreter/execution_errors.rb +1 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +1 -0
- data/lib/graphql/execution/interpreter/resolve.rb +18 -8
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +4 -1
- data/lib/graphql/execution/interpreter/runtime.rb +72 -25
- data/lib/graphql/execution/interpreter.rb +18 -7
- data/lib/graphql/execution/lazy/lazy_method_map.rb +21 -8
- data/lib/graphql/execution/lazy.rb +34 -10
- data/lib/graphql/execution/load_argument_step.rb +1 -0
- data/lib/graphql/execution/lookahead.rb +137 -54
- data/lib/graphql/execution/multiplex.rb +4 -4
- data/lib/graphql/execution/next.rb +7 -0
- data/lib/graphql/execution/prepare_object_step.rb +38 -13
- data/lib/graphql/execution/resolve_type_step.rb +2 -1
- data/lib/graphql/execution/runner.rb +32 -15
- data/lib/graphql/execution/selections_step.rb +3 -2
- data/lib/graphql/execution.rb +2 -2
- data/lib/graphql/execution_error.rb +19 -10
- data/lib/graphql/float_decoding_error.rb +14 -0
- data/lib/graphql/float_encoding_error.rb +33 -0
- data/lib/graphql/integer_decoding_error.rb +2 -1
- data/lib/graphql/integer_encoding_error.rb +8 -3
- data/lib/graphql/introspection/base_object.rb +3 -1
- data/lib/graphql/introspection/directive_location_enum.rb +1 -0
- data/lib/graphql/introspection/directive_type.rb +1 -0
- data/lib/graphql/introspection/dynamic_fields.rb +1 -0
- data/lib/graphql/introspection/entry_points.rb +1 -0
- data/lib/graphql/introspection/enum_value_type.rb +1 -0
- data/lib/graphql/introspection/field_type.rb +1 -0
- data/lib/graphql/introspection/input_value_type.rb +1 -0
- data/lib/graphql/introspection/introspection_query.rb +1 -0
- data/lib/graphql/introspection/schema_type.rb +1 -0
- data/lib/graphql/introspection/type_kind_enum.rb +1 -0
- data/lib/graphql/introspection/type_type.rb +1 -0
- data/lib/graphql/introspection.rb +1 -0
- data/lib/graphql/invalid_name_error.rb +1 -0
- data/lib/graphql/invalid_null_error.rb +19 -6
- data/lib/graphql/language/block_string.rb +2 -1
- data/lib/graphql/language/cache.rb +10 -4
- data/lib/graphql/language/comment.rb +1 -0
- data/lib/graphql/language/definition_slice.rb +1 -0
- data/lib/graphql/language/document_from_schema_definition.rb +9 -10
- data/lib/graphql/language/generation.rb +23 -9
- data/lib/graphql/language/lexer.rb +16 -8
- data/lib/graphql/language/nodes.rb +2094 -419
- data/lib/graphql/language/parser.rb +29 -18
- data/lib/graphql/language/printer.rb +31 -16
- data/lib/graphql/language/sanitized_printer.rb +16 -5
- data/lib/graphql/language/static_visitor.rb +19 -4
- data/lib/graphql/language/visitor.rb +51 -29
- data/lib/graphql/language.rb +15 -9
- data/lib/graphql/load_application_object_failed_error.rb +14 -5
- data/lib/graphql/name_validator.rb +1 -0
- data/lib/graphql/pagination/active_record_relation_connection.rb +1 -0
- data/lib/graphql/pagination/array_connection.rb +24 -6
- data/lib/graphql/pagination/connection.rb +178 -48
- data/lib/graphql/pagination/connections.rb +21 -14
- data/lib/graphql/pagination/mongoid_relation_connection.rb +1 -0
- data/lib/graphql/pagination/relation_connection.rb +164 -27
- data/lib/graphql/pagination/sequel_dataset_connection.rb +1 -0
- data/lib/graphql/pagination.rb +1 -0
- data/lib/graphql/parse_error.rb +1 -0
- data/lib/graphql/query/context/scoped_context.rb +2 -1
- data/lib/graphql/query/context.rb +106 -35
- data/lib/graphql/query/fingerprint.rb +15 -7
- data/lib/graphql/query/input_validation_result.rb +1 -0
- data/lib/graphql/query/null_context.rb +1 -0
- data/lib/graphql/query/partial.rb +28 -16
- data/lib/graphql/query/result.rb +15 -5
- data/lib/graphql/query/validation_pipeline.rb +16 -6
- data/lib/graphql/query/variable_validation_error.rb +17 -1
- data/lib/graphql/query/variables.rb +9 -2
- data/lib/graphql/query.rb +195 -50
- data/lib/graphql/railtie.rb +7 -3
- data/lib/graphql/rake_task/validate.rb +72 -17
- data/lib/graphql/rake_task.rb +55 -23
- data/lib/graphql/relay/range_add.rb +32 -21
- data/lib/graphql/relay.rb +1 -0
- data/lib/graphql/rubocop/graphql/base_cop.rb +1 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +9 -6
- data/lib/graphql/rubocop/graphql/default_required_true.rb +9 -6
- data/lib/graphql/rubocop/graphql/field_type_in_block.rb +12 -8
- data/lib/graphql/rubocop/graphql/root_types_in_block.rb +9 -5
- data/lib/graphql/rubocop.rb +1 -0
- data/lib/graphql/runtime_error.rb +1 -0
- data/lib/graphql/runtime_type_error.rb +1 -0
- data/lib/graphql/schema/addition.rb +69 -50
- data/lib/graphql/schema/always_visible.rb +1 -0
- data/lib/graphql/schema/argument.rb +279 -45
- data/lib/graphql/schema/base_64_encoder.rb +2 -2
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -0
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +2 -2
- data/lib/graphql/schema/build_from_definition.rb +507 -178
- data/lib/graphql/schema/built_in_types.rb +1 -0
- data/lib/graphql/schema/directive/deprecated.rb +1 -0
- data/lib/graphql/schema/directive/feature.rb +39 -22
- data/lib/graphql/schema/directive/flagged.rb +6 -1
- data/lib/graphql/schema/directive/include.rb +1 -0
- data/lib/graphql/schema/directive/one_of.rb +1 -0
- data/lib/graphql/schema/directive/skip.rb +1 -0
- data/lib/graphql/schema/directive/specified_by.rb +1 -0
- data/lib/graphql/schema/directive/transform.rb +17 -8
- data/lib/graphql/schema/directive.rb +33 -7
- data/lib/graphql/schema/enum.rb +99 -38
- data/lib/graphql/schema/enum_value.rb +21 -13
- data/lib/graphql/schema/field/connection_extension.rb +10 -2
- data/lib/graphql/schema/field/scope_extension.rb +1 -0
- data/lib/graphql/schema/field.rb +622 -110
- data/lib/graphql/schema/field_extension.rb +89 -34
- data/lib/graphql/schema/find_inherited_value.rb +5 -3
- data/lib/graphql/schema/finder.rb +22 -8
- data/lib/graphql/schema/has_single_input_argument.rb +39 -6
- data/lib/graphql/schema/input_object.rb +40 -13
- data/lib/graphql/schema/interface.rb +33 -17
- data/lib/graphql/schema/introspection_system.rb +7 -3
- data/lib/graphql/schema/late_bound_type.rb +2 -2
- data/lib/graphql/schema/list.rb +15 -4
- data/lib/graphql/schema/loader.rb +23 -12
- data/lib/graphql/schema/member/base_dsl_methods.rb +58 -12
- data/lib/graphql/schema/member/build_type.rb +21 -7
- data/lib/graphql/schema/member/graphql_type_names.rb +10 -6
- data/lib/graphql/schema/member/has_arguments.rb +112 -49
- data/lib/graphql/schema/member/has_ast_node.rb +1 -0
- data/lib/graphql/schema/member/has_authorization.rb +5 -0
- data/lib/graphql/schema/member/has_dataloader.rb +91 -34
- data/lib/graphql/schema/member/has_deprecation_reason.rb +15 -2
- data/lib/graphql/schema/member/has_directives.rb +45 -11
- data/lib/graphql/schema/member/has_fields.rb +151 -70
- data/lib/graphql/schema/member/has_interfaces.rb +8 -2
- data/lib/graphql/schema/member/has_path.rb +14 -5
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +1 -0
- data/lib/graphql/schema/member/has_validators.rb +19 -4
- data/lib/graphql/schema/member/relay_shortcuts.rb +10 -2
- data/lib/graphql/schema/member/scoped.rb +14 -3
- data/lib/graphql/schema/member/type_system_helpers.rb +36 -6
- data/lib/graphql/schema/member/validates_input.rb +1 -0
- data/lib/graphql/schema/member.rb +9 -2
- data/lib/graphql/schema/mutation.rb +50 -46
- data/lib/graphql/schema/non_null.rb +21 -5
- data/lib/graphql/schema/object.rb +44 -15
- data/lib/graphql/schema/printer.rb +52 -31
- data/lib/graphql/schema/ractor_shareable.rb +6 -2
- data/lib/graphql/schema/relay_classic_mutation.rb +3 -3
- data/lib/graphql/schema/resolver/has_payload_type.rb +29 -7
- data/lib/graphql/schema/resolver.rb +156 -45
- data/lib/graphql/schema/scalar.rb +1 -0
- data/lib/graphql/schema/subscription.rb +67 -28
- data/lib/graphql/schema/timeout.rb +65 -25
- data/lib/graphql/schema/type_expression.rb +14 -5
- data/lib/graphql/schema/type_membership.rb +29 -10
- data/lib/graphql/schema/union.rb +4 -2
- data/lib/graphql/schema/unique_within_type.rb +24 -5
- data/lib/graphql/schema/validator/all_validator.rb +17 -9
- data/lib/graphql/schema/validator/allow_blank_validator.rb +8 -2
- data/lib/graphql/schema/validator/allow_null_validator.rb +8 -2
- data/lib/graphql/schema/validator/exclusion_validator.rb +14 -5
- data/lib/graphql/schema/validator/format_validator.rb +21 -10
- data/lib/graphql/schema/validator/inclusion_validator.rb +15 -6
- data/lib/graphql/schema/validator/length_validator.rb +23 -12
- data/lib/graphql/schema/validator/numericality_validator.rb +29 -16
- data/lib/graphql/schema/validator/required_validator.rb +45 -31
- data/lib/graphql/schema/validator.rb +89 -25
- data/lib/graphql/schema/visibility/migration.rb +14 -7
- data/lib/graphql/schema/visibility/profile.rb +73 -19
- data/lib/graphql/schema/visibility/visit.rb +12 -10
- data/lib/graphql/schema/visibility.rb +24 -20
- data/lib/graphql/schema/warden.rb +117 -31
- data/lib/graphql/schema/wrapper.rb +4 -1
- data/lib/graphql/schema.rb +1052 -304
- data/lib/graphql/static_validation/all_rules.rb +2 -1
- data/lib/graphql/static_validation/base_visitor.rb +59 -9
- data/lib/graphql/static_validation/definition_dependencies.rb +27 -7
- data/lib/graphql/static_validation/error.rb +3 -0
- data/lib/graphql/static_validation/interpreter_visitor.rb +1 -0
- data/lib/graphql/static_validation/literal_validator.rb +1 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +4 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +1 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +3 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +1 -0
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +3 -0
- data/lib/graphql/static_validation/rules/directives_are_defined_error.rb +1 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +3 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +3 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +9 -1
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +355 -157
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +14 -2
- data/lib/graphql/static_validation/rules/fragment_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_named.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_used.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_used_error.rb +1 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +3 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +3 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/not_single_subscription_error.rb +1 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +4 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +1 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid.rb +3 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid_error.rb +1 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +3 -0
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +4 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/subscription_root_exists_and_single_subscription_selection.rb +43 -5
- data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +3 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +3 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +207 -51
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +3 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +6 -3
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb +1 -0
- data/lib/graphql/static_validation/validation_context.rb +3 -2
- data/lib/graphql/static_validation/validation_timeout_error.rb +1 -0
- data/lib/graphql/static_validation/validator.rb +41 -16
- data/lib/graphql/static_validation.rb +1 -0
- data/lib/graphql/string_encoding_error.rb +1 -0
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +85 -65
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +10 -4
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +1 -0
- data/lib/graphql/subscriptions/event.rb +25 -6
- data/lib/graphql/subscriptions/serialize.rb +89 -23
- data/lib/graphql/subscriptions.rb +172 -46
- data/lib/graphql/testing/helpers.rb +17 -4
- data/lib/graphql/testing/mock_action_cable.rb +55 -33
- data/lib/graphql/testing.rb +1 -0
- data/lib/graphql/tracing/active_support_notifications_trace.rb +17 -9
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +2 -1
- data/lib/graphql/tracing/appoptics_trace.rb +2 -1
- data/lib/graphql/tracing/appoptics_tracing.rb +2 -1
- data/lib/graphql/tracing/appsignal_trace.rb +16 -7
- data/lib/graphql/tracing/appsignal_tracing.rb +7 -3
- data/lib/graphql/tracing/call_legacy_tracers.rb +1 -0
- data/lib/graphql/tracing/data_dog_trace.rb +17 -6
- data/lib/graphql/tracing/data_dog_tracing.rb +10 -3
- data/lib/graphql/tracing/detailed_trace/active_record_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace/memory_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace/redis_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace.rb +105 -42
- data/lib/graphql/tracing/legacy_hooks_trace.rb +5 -0
- data/lib/graphql/tracing/legacy_trace.rb +1 -0
- data/lib/graphql/tracing/monitor_trace.rb +17 -11
- data/lib/graphql/tracing/new_relic_trace.rb +17 -8
- data/lib/graphql/tracing/new_relic_tracing.rb +7 -3
- data/lib/graphql/tracing/notifications_trace.rb +11 -8
- data/lib/graphql/tracing/notifications_tracing.rb +23 -7
- data/lib/graphql/tracing/null_trace.rb +1 -0
- data/lib/graphql/tracing/perfetto_trace/trace_pb.rb +1 -0
- data/lib/graphql/tracing/perfetto_trace.rb +41 -19
- data/lib/graphql/tracing/platform_trace.rb +3 -1
- data/lib/graphql/tracing/platform_tracing.rb +16 -7
- data/lib/graphql/tracing/prometheus_trace/graphql_collector.rb +1 -0
- data/lib/graphql/tracing/prometheus_trace.rb +22 -13
- data/lib/graphql/tracing/prometheus_tracing.rb +1 -0
- data/lib/graphql/tracing/scout_trace.rb +10 -4
- data/lib/graphql/tracing/scout_tracing.rb +7 -3
- data/lib/graphql/tracing/sentry_trace.rb +25 -6
- data/lib/graphql/tracing/statsd_trace.rb +12 -6
- data/lib/graphql/tracing/statsd_tracing.rb +7 -1
- data/lib/graphql/tracing/trace.rb +231 -58
- data/lib/graphql/tracing.rb +25 -9
- data/lib/graphql/type_kinds.rb +2 -1
- data/lib/graphql/types/big_int.rb +1 -0
- data/lib/graphql/types/boolean.rb +1 -0
- data/lib/graphql/types/float.rb +19 -4
- data/lib/graphql/types/id.rb +1 -0
- data/lib/graphql/types/int.rb +2 -1
- data/lib/graphql/types/iso_8601_date.rb +21 -4
- data/lib/graphql/types/iso_8601_date_time.rb +33 -6
- data/lib/graphql/types/iso_8601_duration.rb +42 -9
- data/lib/graphql/types/json.rb +1 -0
- data/lib/graphql/types/relay/base_connection.rb +38 -32
- data/lib/graphql/types/relay/base_edge.rb +15 -9
- data/lib/graphql/types/relay/connection_behaviors.rb +19 -3
- data/lib/graphql/types/relay/edge_behaviors.rb +17 -4
- data/lib/graphql/types/relay/has_node_field.rb +6 -1
- data/lib/graphql/types/relay/has_nodes_field.rb +6 -1
- data/lib/graphql/types/relay/node.rb +1 -0
- data/lib/graphql/types/relay/node_behaviors.rb +5 -1
- data/lib/graphql/types/relay/page_info.rb +1 -0
- data/lib/graphql/types/relay/page_info_behaviors.rb +1 -0
- data/lib/graphql/types/relay.rb +4 -3
- data/lib/graphql/types/string.rb +1 -0
- data/lib/graphql/types.rb +1 -0
- data/lib/graphql/unauthorized_enum_value_error.rb +4 -1
- data/lib/graphql/unauthorized_error.rb +11 -4
- data/lib/graphql/unauthorized_field_error.rb +4 -1
- data/lib/graphql/unresolved_type_error.rb +16 -5
- data/lib/graphql/version.rb +2 -1
- data/lib/graphql.rb +39 -9
- data/readme.md +1 -1
- metadata +91 -5
- data/.yardopts +0 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Schema
|
|
4
5
|
class Directive < GraphQL::Schema::Member
|
|
@@ -12,27 +13,35 @@ module GraphQL
|
|
|
12
13
|
#
|
|
13
14
|
# To use it, you have to implement `.enabled?`, for example:
|
|
14
15
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
16
|
+
# **Examples**
|
|
17
|
+
#
|
|
18
|
+
# **Example: Implementing the Feature directive**
|
|
19
|
+
#
|
|
20
|
+
# ```ruby
|
|
21
|
+
# # app/graphql/directives/feature.rb
|
|
22
|
+
# class Directives::Feature < GraphQL::Schema::Directive::Feature
|
|
23
|
+
# def self.enabled?(flag_name, _obj, context)
|
|
24
|
+
# # Translate some GraphQL data for Ruby:
|
|
25
|
+
# flag_key = flag_name.underscore
|
|
26
|
+
# current_user = context[:viewer]
|
|
27
|
+
# # Check the feature flag however your app does it:
|
|
28
|
+
# MyFeatureFlags.enabled?(current_user, flag_key)
|
|
25
29
|
# end
|
|
30
|
+
# end
|
|
31
|
+
# ```
|
|
26
32
|
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
33
|
+
# **Example: Flagging a part of the query**
|
|
34
|
+
#
|
|
35
|
+
# ```ruby
|
|
36
|
+
# viewer {
|
|
37
|
+
# # This field only runs if `.enabled?("recommendationEngine", obj, context)`
|
|
38
|
+
# # returns true. Otherwise, it's treated as if it didn't exist.
|
|
39
|
+
# recommendations @feature(flag: "recommendationEngine") {
|
|
40
|
+
# name
|
|
41
|
+
# rating
|
|
35
42
|
# }
|
|
43
|
+
# }
|
|
44
|
+
# ```
|
|
36
45
|
class Feature < Schema::Directive
|
|
37
46
|
description "Directs the executor to run this only if a certain server-side feature is enabled."
|
|
38
47
|
|
|
@@ -53,10 +62,18 @@ module GraphQL
|
|
|
53
62
|
|
|
54
63
|
# Override this method in your app's subclass of this directive.
|
|
55
64
|
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
#
|
|
65
|
+
# **Parameters**
|
|
66
|
+
#
|
|
67
|
+
# - `flag_name` (`String`) — The client-provided string of a feature to check
|
|
68
|
+
# - `object` (`GraphQL::Schema::Objct`) — The currently-evaluated GraphQL object instance
|
|
69
|
+
# - `context` (`GraphQL::Query::Context`)
|
|
70
|
+
#
|
|
71
|
+
# **Returns**
|
|
72
|
+
#
|
|
73
|
+
# - `Boolean` — If truthy, execution will continue
|
|
74
|
+
#
|
|
75
|
+
# :call-seq:
|
|
76
|
+
# enabled?(String flag_name, GraphQL::Schema::Objct object, GraphQL::Query::Context context) -> bool
|
|
60
77
|
def self.enabled?(flag_name, object, context)
|
|
61
78
|
raise GraphQL::RequiredImplementationMissingError, "Implement `.enabled?(flag_name, object, context)` to return true or false for the feature flag (#{flag_name.inspect})"
|
|
62
79
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Schema
|
|
4
5
|
class Directive < GraphQL::Schema::Member
|
|
5
|
-
# This is _similar_ to
|
|
6
|
+
# This is _similar_ to [Directive::Feature](rdoc-ref:Directive::Feature), except it's prescribed by the server, not the client.
|
|
6
7
|
#
|
|
7
8
|
# In this case, the server hides types and fields _entirely_, unless the current context has certain `:flags` present.
|
|
8
9
|
class Flagged < GraphQL::Schema::Directive
|
|
@@ -39,6 +40,10 @@ module GraphQL
|
|
|
39
40
|
|
|
40
41
|
repeatable(true)
|
|
41
42
|
|
|
43
|
+
#--
|
|
44
|
+
|
|
45
|
+
# @requires_ancestor: GraphQL::Schema::Member::HasDirectives
|
|
46
|
+
|
|
42
47
|
module VisibleByFlag
|
|
43
48
|
def self.included(schema_class)
|
|
44
49
|
schema_class.extend(self)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Schema
|
|
4
5
|
class Directive < GraphQL::Schema::Member
|
|
@@ -8,15 +9,23 @@ module GraphQL
|
|
|
8
9
|
# and if the named transform is whitelisted and applies to the return value,
|
|
9
10
|
# it's applied by calling a method with that name.
|
|
10
11
|
#
|
|
11
|
-
#
|
|
12
|
-
# class MySchema < GraphQL::Schema
|
|
13
|
-
# directive(GraphQL::Schema::Directive::Transform)
|
|
14
|
-
# end
|
|
12
|
+
# **Examples**
|
|
15
13
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
14
|
+
# **Example: Installing the directive**
|
|
15
|
+
#
|
|
16
|
+
# ```ruby
|
|
17
|
+
# class MySchema < GraphQL::Schema
|
|
18
|
+
# directive(GraphQL::Schema::Directive::Transform)
|
|
19
|
+
# end
|
|
20
|
+
# ```
|
|
21
|
+
#
|
|
22
|
+
# **Example: Transforming strings**
|
|
23
|
+
#
|
|
24
|
+
# ```ruby
|
|
25
|
+
# viewer {
|
|
26
|
+
# username @transform(by: "upcase")
|
|
27
|
+
# }
|
|
28
|
+
# ```
|
|
20
29
|
class Transform < Schema::Directive
|
|
21
30
|
description "Directs the executor to run named transform on the return value."
|
|
22
31
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
5
|
-
# Subclasses of this can influence how
|
|
6
|
+
# Subclasses of this can influence how [GraphQL::Execution::Interpreter](rdoc-ref:GraphQL::Execution::Interpreter) runs queries.
|
|
6
7
|
#
|
|
7
|
-
# -
|
|
8
|
-
# -
|
|
8
|
+
# - [.include?](rdoc-ref:.include?): if it returns `false`, the field or fragment will be skipped altogether, as if it were absent
|
|
9
|
+
# - [.resolve](rdoc-ref:.resolve): Wraps field resolution (so it should call `yield` to continue)
|
|
9
10
|
class Directive < GraphQL::Schema::Member
|
|
10
11
|
extend GraphQL::Schema::Member::HasArguments
|
|
11
12
|
extend GraphQL::Schema::Member::HasArguments::HasDirectiveArguments
|
|
@@ -31,7 +32,7 @@ module GraphQL
|
|
|
31
32
|
|
|
32
33
|
def locations(*new_locations)
|
|
33
34
|
if !new_locations.empty?
|
|
34
|
-
is_runtime = false
|
|
35
|
+
is_runtime = false #: bool
|
|
35
36
|
new_locations.each do |new_loc|
|
|
36
37
|
loc_sym = new_loc.to_sym
|
|
37
38
|
if !LOCATIONS.include?(loc_sym)
|
|
@@ -69,7 +70,7 @@ module GraphQL
|
|
|
69
70
|
static_include?(arguments, context)
|
|
70
71
|
end
|
|
71
72
|
|
|
72
|
-
# Determines whether
|
|
73
|
+
# Determines whether [Execution::Lookahead](rdoc-ref:Execution::Lookahead) considers the field to be selected
|
|
73
74
|
def static_include?(_arguments, _context)
|
|
74
75
|
true
|
|
75
76
|
end
|
|
@@ -84,6 +85,11 @@ module GraphQL
|
|
|
84
85
|
yield
|
|
85
86
|
end
|
|
86
87
|
|
|
88
|
+
def resolve_field(...); end
|
|
89
|
+
def resolve_fragment_spread(...); end
|
|
90
|
+
def resolve_inline_fragment(...); end
|
|
91
|
+
def resolve_operation(...); end
|
|
92
|
+
|
|
87
93
|
def validate!(arguments, context)
|
|
88
94
|
Schema::Validator.validate!(validators, self, context, arguments)
|
|
89
95
|
end
|
|
@@ -108,6 +114,10 @@ module GraphQL
|
|
|
108
114
|
@repeatable = new_value
|
|
109
115
|
end
|
|
110
116
|
|
|
117
|
+
# When this is a Hash, instances with equal, statically coercible arguments reuse the first instance's coerced arguments.
|
|
118
|
+
# BuildFromDefinition uses this while it builds a schema, then removes it.
|
|
119
|
+
attr_accessor :coerced_arguments_cache # :nodoc:
|
|
120
|
+
|
|
111
121
|
private
|
|
112
122
|
|
|
113
123
|
def inherited(subclass)
|
|
@@ -118,14 +128,19 @@ module GraphQL
|
|
|
118
128
|
@locations = parent_class.locations
|
|
119
129
|
@is_runtime = parent_class.runtime?
|
|
120
130
|
@repeatable = false
|
|
131
|
+
@coerced_arguments_cache = nil
|
|
121
132
|
end
|
|
122
133
|
end
|
|
123
134
|
end
|
|
124
135
|
|
|
125
|
-
#
|
|
136
|
+
# **Returns**
|
|
137
|
+
#
|
|
138
|
+
# - `GraphQL::Schema::Field, GraphQL::Schema::Argument, Class, Module`
|
|
126
139
|
attr_reader :owner
|
|
127
140
|
|
|
128
|
-
#
|
|
141
|
+
# **Returns**
|
|
142
|
+
#
|
|
143
|
+
# - `GraphQL::Interpreter::Arguments`
|
|
129
144
|
attr_reader :arguments
|
|
130
145
|
|
|
131
146
|
class InvalidArgumentError < GraphQL::Error
|
|
@@ -134,6 +149,14 @@ module GraphQL
|
|
|
134
149
|
def initialize(owner, **arguments)
|
|
135
150
|
@owner = owner
|
|
136
151
|
assert_valid_owner
|
|
152
|
+
if (arguments_cache = self.class.coerced_arguments_cache)
|
|
153
|
+
if !self.class.arguments_statically_coercible?
|
|
154
|
+
arguments_cache = nil
|
|
155
|
+
elsif (cached_arguments = arguments_cache[arguments])
|
|
156
|
+
@arguments = cached_arguments
|
|
157
|
+
return
|
|
158
|
+
end
|
|
159
|
+
end
|
|
137
160
|
# It's be nice if we had the real context here, but we don't. What we _would_ get is:
|
|
138
161
|
# - error handling
|
|
139
162
|
# - lazy resolution
|
|
@@ -185,6 +208,9 @@ module GraphQL
|
|
|
185
208
|
if @arguments.is_a?(GraphQL::ExecutionError)
|
|
186
209
|
raise @arguments
|
|
187
210
|
end
|
|
211
|
+
if arguments_cache
|
|
212
|
+
arguments_cache[arguments] = @arguments
|
|
213
|
+
end
|
|
188
214
|
end
|
|
189
215
|
|
|
190
216
|
def graphql_name
|
data/lib/graphql/schema/enum.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
@@ -7,18 +8,22 @@ module GraphQL
|
|
|
7
8
|
# By default, GraphQL enum values are translated into Ruby strings.
|
|
8
9
|
# You can provide a custom value with the `value:` keyword.
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
11
|
+
# **Examples**
|
|
12
|
+
#
|
|
13
|
+
# **Example: # equivalent to**
|
|
14
|
+
#
|
|
15
|
+
# ```ruby
|
|
16
|
+
# # enum PizzaTopping {
|
|
17
|
+
# # MUSHROOMS
|
|
18
|
+
# # ONIONS
|
|
19
|
+
# # PEPPERS
|
|
20
|
+
# # }
|
|
21
|
+
# class PizzaTopping < GraphQL::Schema::Enum
|
|
22
|
+
# value :MUSHROOMS
|
|
23
|
+
# value :ONIONS
|
|
24
|
+
# value :PEPPERS
|
|
25
|
+
# end
|
|
26
|
+
# ```
|
|
22
27
|
class Enum < GraphQL::Schema::Member
|
|
23
28
|
extend GraphQL::Schema::Member::ValidatesInput
|
|
24
29
|
|
|
@@ -29,7 +34,7 @@ module GraphQL
|
|
|
29
34
|
#
|
|
30
35
|
# In either case, the field should be modified so that the invalid value isn't returned.
|
|
31
36
|
#
|
|
32
|
-
#
|
|
37
|
+
# [GraphQL::Schema::Enum](rdoc-ref:GraphQL::Schema::Enum) subclasses get their own subclass of this error, so that bug trackers can better show where they came from.
|
|
33
38
|
class UnresolvedValueError < GraphQL::Error
|
|
34
39
|
def initialize(value:, enum:, context:, authorized:)
|
|
35
40
|
fix_message = if authorized == false
|
|
@@ -46,7 +51,7 @@ module GraphQL
|
|
|
46
51
|
end
|
|
47
52
|
end
|
|
48
53
|
|
|
49
|
-
# Raised when a
|
|
54
|
+
# Raised when a [GraphQL::Schema::Enum](rdoc-ref:GraphQL::Schema::Enum) is defined to have no values.
|
|
50
55
|
# This can also happen when all values return false for `.visible?`.
|
|
51
56
|
class MissingValuesError < GraphQL::Error
|
|
52
57
|
def initialize(enum_type)
|
|
@@ -57,15 +62,27 @@ module GraphQL
|
|
|
57
62
|
|
|
58
63
|
class << self
|
|
59
64
|
# Define a value for this enum
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
#
|
|
65
|
+
# See [Schema::EnumValue](rdoc-ref:Schema::EnumValue) which handles these inputs by default
|
|
66
|
+
#
|
|
67
|
+
# **Options**
|
|
68
|
+
#
|
|
69
|
+
# - `kwargs.:graphql_name` (`String, Symbol`) — the GraphQL value for this, usually `SCREAMING_CASE`
|
|
70
|
+
# - `kwargs.:description,` (`String`) — the GraphQL description for this value, present in documentation
|
|
71
|
+
# - `kwargs.:comment,` (`String`) — the GraphQL comment for this value, present in documentation
|
|
72
|
+
# - `kwargs.:value` (`::Object`) — the translated Ruby value for this object (defaults to `graphql_name`)
|
|
73
|
+
# - `kwargs.:value_method,` (`::Object`) — the method name to fetch `graphql_name` (defaults to `graphql_name.downcase`)
|
|
74
|
+
# - `kwargs.:deprecation_reason` (`String`) — if this object is deprecated, include a message here
|
|
75
|
+
#
|
|
76
|
+
# **Parameters**
|
|
77
|
+
#
|
|
78
|
+
# - `value_method` (`Symbol, false`) — A method to generate for this value, or `false` to skip generation
|
|
79
|
+
#
|
|
80
|
+
# **Returns**
|
|
81
|
+
#
|
|
82
|
+
# - `void`
|
|
83
|
+
#
|
|
84
|
+
# :call-seq:
|
|
85
|
+
# value(*args, Symbol | false value_method:, **kwargs, &block) -> void
|
|
69
86
|
def value(*args, value_method: nil, **kwargs, &block)
|
|
70
87
|
kwargs[:owner] = self
|
|
71
88
|
value = enum_value_class.new(*args, **kwargs, &block)
|
|
@@ -89,13 +106,18 @@ module GraphQL
|
|
|
89
106
|
value
|
|
90
107
|
end
|
|
91
108
|
|
|
92
|
-
#
|
|
109
|
+
# **Returns**
|
|
110
|
+
#
|
|
111
|
+
# - `Array<GraphQL::Schema::EnumValue>` — Possible values of this enum
|
|
112
|
+
#
|
|
113
|
+
# :call-seq:
|
|
114
|
+
# enum_values(context:) -> Array[GraphQL::Schema::EnumValue]
|
|
93
115
|
def enum_values(context = GraphQL::Query::NullContext.instance)
|
|
94
116
|
inherited_values = superclass.respond_to?(:enum_values) ? superclass.enum_values(context) : nil
|
|
95
117
|
visible_values = []
|
|
96
118
|
types = Warden.types_from_context(context)
|
|
97
119
|
own_values.each do |key, values_entry|
|
|
98
|
-
visible_value = nil
|
|
120
|
+
visible_value = nil #: GraphQL::Schema::EnumValue?
|
|
99
121
|
if values_entry.is_a?(Array)
|
|
100
122
|
values_entry.each do |v|
|
|
101
123
|
if types.visible_enum_value?(v, context)
|
|
@@ -126,7 +148,12 @@ module GraphQL
|
|
|
126
148
|
visible_values
|
|
127
149
|
end
|
|
128
150
|
|
|
129
|
-
#
|
|
151
|
+
# **Returns**
|
|
152
|
+
#
|
|
153
|
+
# - `Array<Schema::EnumValue>` — An unfiltered list of all definitions
|
|
154
|
+
#
|
|
155
|
+
# :call-seq:
|
|
156
|
+
# all_enum_value_definitions() -> Array[Schema::EnumValue]
|
|
130
157
|
def all_enum_value_definitions
|
|
131
158
|
all_defns = if superclass.respond_to?(:all_enum_value_definitions)
|
|
132
159
|
superclass.all_enum_value_definitions
|
|
@@ -145,12 +172,22 @@ module GraphQL
|
|
|
145
172
|
all_defns
|
|
146
173
|
end
|
|
147
174
|
|
|
148
|
-
#
|
|
175
|
+
# **Returns**
|
|
176
|
+
#
|
|
177
|
+
# - `Hash<String => GraphQL::Schema::EnumValue>` — Possible values of this enum, keyed by name.
|
|
178
|
+
#
|
|
179
|
+
# :call-seq:
|
|
180
|
+
# values(context:) -> Hash[String, GraphQL::Schema::EnumValue]
|
|
149
181
|
def values(context = GraphQL::Query::NullContext.instance)
|
|
150
182
|
enum_values(context).each_with_object({}) { |val, obj| obj[val.graphql_name] = val }
|
|
151
183
|
end
|
|
152
184
|
|
|
153
|
-
#
|
|
185
|
+
# **Returns**
|
|
186
|
+
#
|
|
187
|
+
# - `Class` — for handling `value(...)` inputs and building `GraphQL::Enum::EnumValue`s out of them
|
|
188
|
+
#
|
|
189
|
+
# :call-seq:
|
|
190
|
+
# enum_value_class(new_enum_value_class) -> Class
|
|
154
191
|
def enum_value_class(new_enum_value_class = nil)
|
|
155
192
|
if new_enum_value_class
|
|
156
193
|
@enum_value_class = new_enum_value_class
|
|
@@ -191,11 +228,23 @@ module GraphQL
|
|
|
191
228
|
end
|
|
192
229
|
|
|
193
230
|
# Called by the runtime when a field returns a value to give back to the client.
|
|
194
|
-
# This method checks that the incoming
|
|
195
|
-
#
|
|
196
|
-
#
|
|
197
|
-
#
|
|
198
|
-
#
|
|
231
|
+
# This method checks that the incoming [value](rdoc-ref:value) matches one of the enum's defined values.
|
|
232
|
+
#
|
|
233
|
+
# **Parameters**
|
|
234
|
+
#
|
|
235
|
+
# - `value` (`Object`) — Any value matching the values for this enum.
|
|
236
|
+
# - `ctx` (`GraphQL::Query::Context`)
|
|
237
|
+
#
|
|
238
|
+
# **Raises**
|
|
239
|
+
#
|
|
240
|
+
# - `GraphQL::Schema::Enum::UnresolvedValueError` — if [value](rdoc-ref:value) doesn't match a configured value or if the matching value isn't authorized.
|
|
241
|
+
#
|
|
242
|
+
# **Returns**
|
|
243
|
+
#
|
|
244
|
+
# - `String` — The GraphQL-ready string for [value](rdoc-ref:value)
|
|
245
|
+
#
|
|
246
|
+
# :call-seq:
|
|
247
|
+
# coerce_result(Object value, GraphQL::Query::Context ctx) -> String
|
|
199
248
|
def coerce_result(value, ctx)
|
|
200
249
|
types = ctx.types
|
|
201
250
|
all_values = types ? types.enum_values(self) : values.each_value
|
|
@@ -203,16 +252,28 @@ module GraphQL
|
|
|
203
252
|
if enum_value && (was_authed = enum_value.authorized?(ctx))
|
|
204
253
|
enum_value.graphql_name
|
|
205
254
|
else
|
|
206
|
-
raise
|
|
255
|
+
raise const_get(:UnresolvedValueError).new(enum: self, value: value, context: ctx, authorized: was_authed)
|
|
207
256
|
end
|
|
208
257
|
end
|
|
209
258
|
|
|
210
259
|
# Called by the runtime with incoming string representations from a query.
|
|
211
260
|
# It will match the string to a configured by name or by Ruby value.
|
|
212
|
-
#
|
|
213
|
-
#
|
|
214
|
-
#
|
|
215
|
-
#
|
|
261
|
+
#
|
|
262
|
+
# **Parameters**
|
|
263
|
+
#
|
|
264
|
+
# - `value_name` (`String, Object`) — A string from a GraphQL query, or a Ruby value matching a `value(..., value: ...)` configuration
|
|
265
|
+
# - `ctx` (`GraphQL::Query::Context`)
|
|
266
|
+
#
|
|
267
|
+
# **Raises**
|
|
268
|
+
#
|
|
269
|
+
# - `GraphQL::UnauthorizedEnumValueError` — if an [EnumValue](rdoc-ref:EnumValue) matches but returns false for `.authorized?`. Goes to [Schema.unauthorized_object](rdoc-ref:Schema.unauthorized_object).
|
|
270
|
+
#
|
|
271
|
+
# **Returns**
|
|
272
|
+
#
|
|
273
|
+
# - `Object` — The Ruby value for the matched [GraphQL::Schema::EnumValue](rdoc-ref:GraphQL::Schema::EnumValue)
|
|
274
|
+
#
|
|
275
|
+
# :call-seq:
|
|
276
|
+
# coerce_input(String | Object value_name, GraphQL::Query::Context ctx) -> Object
|
|
216
277
|
def coerce_input(value_name, ctx)
|
|
217
278
|
all_values = ctx.types ? ctx.types.enum_values(self) : values.each_value
|
|
218
279
|
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
5
|
-
# A possible value for an
|
|
6
|
+
# A possible value for an [Enum](rdoc-ref:Enum).
|
|
6
7
|
#
|
|
7
8
|
# You can extend this class to customize enum values in your schema.
|
|
8
9
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
# def initialize(*args)
|
|
13
|
-
# # arguments to `value(...)` in Enum classes are passed here
|
|
14
|
-
# super
|
|
15
|
-
# end
|
|
16
|
-
# end
|
|
10
|
+
# **Examples**
|
|
11
|
+
#
|
|
12
|
+
# **Example: custom enum value class**
|
|
17
13
|
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
14
|
+
# ```ruby
|
|
15
|
+
# # define a custom class:
|
|
16
|
+
# class CustomEnumValue < GraphQL::Schema::EnumValue
|
|
17
|
+
# def initialize(*args)
|
|
18
|
+
# # arguments to `value(...)` in Enum classes are passed here
|
|
19
|
+
# super
|
|
21
20
|
# end
|
|
21
|
+
# end
|
|
22
|
+
#
|
|
23
|
+
# class BaseEnum < GraphQL::Schema::Enum
|
|
24
|
+
# # use it for these enums:
|
|
25
|
+
# enum_value_class CustomEnumValue
|
|
26
|
+
# end
|
|
27
|
+
# ```
|
|
22
28
|
class EnumValue < GraphQL::Schema::Member
|
|
23
29
|
include GraphQL::Schema::Member::HasPath
|
|
24
30
|
include GraphQL::Schema::Member::HasAstNode
|
|
@@ -27,7 +33,9 @@ module GraphQL
|
|
|
27
33
|
|
|
28
34
|
attr_reader :graphql_name
|
|
29
35
|
|
|
30
|
-
#
|
|
36
|
+
# **Returns**
|
|
37
|
+
#
|
|
38
|
+
# - `Class` — The enum type that owns this value
|
|
31
39
|
attr_reader :owner
|
|
32
40
|
|
|
33
41
|
def initialize(graphql_name, desc = nil, owner:, ast_node: nil, directives: nil, description: nil, comment: nil, value: NOT_CONFIGURED, deprecation_reason: nil, &block)
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
5
6
|
class Field
|
|
6
7
|
class ConnectionExtension < GraphQL::Schema::FieldExtension
|
|
8
|
+
extras [:lookahead]
|
|
9
|
+
|
|
7
10
|
def apply
|
|
8
11
|
field.argument :after, "String", "Returns the elements in the list that come after the specified cursor.", required: false
|
|
9
12
|
field.argument :before, "String", "Returns the elements in the list that come before the specified cursor.", required: false
|
|
@@ -18,13 +21,18 @@ module GraphQL
|
|
|
18
21
|
next_args.delete(:last)
|
|
19
22
|
next_args.delete(:before)
|
|
20
23
|
next_args.delete(:after)
|
|
21
|
-
|
|
24
|
+
# Keep the extension's extras (`:lookahead`) out of `connection.arguments`
|
|
25
|
+
original_arguments = added_extras ? arguments.reject { |k, _v| added_extras.include?(k) } : arguments
|
|
26
|
+
yield(object || objects, next_args, original_arguments)
|
|
22
27
|
end
|
|
23
28
|
|
|
24
29
|
def after_resolve(value:, object:, arguments:, context:, memo:)
|
|
25
30
|
original_arguments = memo
|
|
31
|
+
lookahead = arguments[:lookahead]
|
|
26
32
|
context.query.after_lazy(value) do |resolved_value|
|
|
27
|
-
context.schema.connections.populate_connection(field, object.object, resolved_value, original_arguments, context)
|
|
33
|
+
connection = context.schema.connections.populate_connection(field, object.object, resolved_value, original_arguments, context)
|
|
34
|
+
connection.lookahead ||= lookahead if connection.is_a?(GraphQL::Pagination::Connection)
|
|
35
|
+
connection
|
|
28
36
|
end
|
|
29
37
|
end
|
|
30
38
|
end
|