graphql 2.6.12 → 2.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rdoc_options +4 -0
- data/lib/generators/graphql/core.rb +1 -0
- data/lib/generators/graphql/detailed_trace_generator.rb +1 -0
- data/lib/generators/graphql/enum_generator.rb +1 -0
- data/lib/generators/graphql/field_extractor.rb +1 -0
- data/lib/generators/graphql/input_generator.rb +1 -0
- data/lib/generators/graphql/install/mutation_root_generator.rb +1 -0
- data/lib/generators/graphql/install_generator.rb +1 -0
- data/lib/generators/graphql/interface_generator.rb +1 -0
- data/lib/generators/graphql/loader_generator.rb +8 -2
- data/lib/generators/graphql/mutation_create_generator.rb +8 -2
- data/lib/generators/graphql/mutation_delete_generator.rb +8 -2
- data/lib/generators/graphql/mutation_generator.rb +8 -2
- data/lib/generators/graphql/mutation_update_generator.rb +8 -2
- data/lib/generators/graphql/object_generator.rb +1 -0
- data/lib/generators/graphql/orm_mutations_base.rb +8 -2
- data/lib/generators/graphql/relay.rb +1 -0
- data/lib/generators/graphql/relay_generator.rb +1 -0
- data/lib/generators/graphql/scalar_generator.rb +1 -0
- data/lib/generators/graphql/type_generator.rb +38 -8
- data/lib/generators/graphql/union_generator.rb +1 -0
- data/lib/graphql/analysis/analyzer.rb +35 -9
- data/lib/graphql/analysis/field_usage.rb +1 -0
- data/lib/graphql/analysis/max_query_complexity.rb +2 -1
- data/lib/graphql/analysis/max_query_depth.rb +1 -0
- data/lib/graphql/analysis/query_complexity.rb +57 -20
- data/lib/graphql/analysis/query_depth.rb +17 -12
- data/lib/graphql/analysis/visitor.rb +79 -16
- data/lib/graphql/analysis.rb +23 -6
- data/lib/graphql/analysis_error.rb +1 -0
- data/lib/graphql/autoload.rb +30 -7
- data/lib/graphql/backtrace/table.rb +21 -5
- data/lib/graphql/backtrace/traced_error.rb +8 -3
- data/lib/graphql/backtrace.rb +14 -9
- data/lib/graphql/coercion_error.rb +1 -0
- data/lib/graphql/current.rb +44 -19
- data/lib/graphql/dashboard/application_controller.rb +1 -0
- data/lib/graphql/dashboard/detailed_traces.rb +1 -0
- data/lib/graphql/dashboard/installable.rb +1 -0
- data/lib/graphql/dashboard/landings_controller.rb +1 -0
- data/lib/graphql/dashboard/limiters.rb +1 -0
- data/lib/graphql/dashboard/operation_store.rb +1 -0
- data/lib/graphql/dashboard/statics_controller.rb +1 -0
- data/lib/graphql/dashboard/subscriptions.rb +1 -0
- data/lib/graphql/dashboard.rb +36 -22
- data/lib/graphql/dataloader/active_record_association_source.rb +1 -0
- data/lib/graphql/dataloader/active_record_source.rb +1 -0
- data/lib/graphql/dataloader/async_dataloader.rb +8 -7
- data/lib/graphql/dataloader/null_dataloader.rb +4 -3
- data/lib/graphql/dataloader/request.rb +8 -2
- data/lib/graphql/dataloader/request_all.rb +8 -2
- data/lib/graphql/dataloader/source.rb +127 -35
- data/lib/graphql/dataloader.rb +91 -42
- data/lib/graphql/date_encoding_error.rb +2 -1
- data/lib/graphql/dig.rb +12 -3
- data/lib/graphql/duration_encoding_error.rb +2 -1
- data/lib/graphql/execution/directive_checks.rb +8 -3
- data/lib/graphql/execution/errors.rb +20 -6
- data/lib/graphql/execution/field_resolve_step.rb +22 -6
- data/lib/graphql/execution/finalize.rb +12 -6
- data/lib/graphql/execution/input_values.rb +2 -1
- data/lib/graphql/execution/interpreter/argument_value.rb +17 -5
- data/lib/graphql/execution/interpreter/arguments.rb +24 -9
- data/lib/graphql/execution/interpreter/arguments_cache.rb +2 -1
- data/lib/graphql/execution/interpreter/execution_errors.rb +1 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +1 -0
- data/lib/graphql/execution/interpreter/resolve.rb +18 -8
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +4 -1
- data/lib/graphql/execution/interpreter/runtime.rb +66 -23
- data/lib/graphql/execution/interpreter.rb +15 -6
- data/lib/graphql/execution/lazy/lazy_method_map.rb +21 -8
- data/lib/graphql/execution/lazy.rb +34 -10
- data/lib/graphql/execution/load_argument_step.rb +1 -0
- data/lib/graphql/execution/lookahead.rb +137 -54
- data/lib/graphql/execution/multiplex.rb +4 -4
- data/lib/graphql/execution/next.rb +7 -0
- data/lib/graphql/execution/prepare_object_step.rb +1 -0
- data/lib/graphql/execution/resolve_type_step.rb +2 -1
- data/lib/graphql/execution/runner.rb +9 -3
- data/lib/graphql/execution/selections_step.rb +3 -2
- data/lib/graphql/execution.rb +2 -2
- data/lib/graphql/execution_error.rb +19 -10
- data/lib/graphql/float_decoding_error.rb +1 -0
- data/lib/graphql/float_encoding_error.rb +7 -2
- data/lib/graphql/integer_decoding_error.rb +2 -1
- data/lib/graphql/integer_encoding_error.rb +8 -3
- data/lib/graphql/introspection/base_object.rb +3 -1
- data/lib/graphql/introspection/directive_location_enum.rb +1 -0
- data/lib/graphql/introspection/directive_type.rb +1 -0
- data/lib/graphql/introspection/dynamic_fields.rb +1 -0
- data/lib/graphql/introspection/entry_points.rb +1 -0
- data/lib/graphql/introspection/enum_value_type.rb +1 -0
- data/lib/graphql/introspection/field_type.rb +1 -0
- data/lib/graphql/introspection/input_value_type.rb +1 -0
- data/lib/graphql/introspection/introspection_query.rb +1 -0
- data/lib/graphql/introspection/schema_type.rb +1 -0
- data/lib/graphql/introspection/type_kind_enum.rb +1 -0
- data/lib/graphql/introspection/type_type.rb +1 -0
- data/lib/graphql/introspection.rb +1 -0
- data/lib/graphql/invalid_name_error.rb +1 -0
- data/lib/graphql/invalid_null_error.rb +19 -6
- data/lib/graphql/language/block_string.rb +2 -1
- data/lib/graphql/language/cache.rb +10 -4
- data/lib/graphql/language/comment.rb +1 -0
- data/lib/graphql/language/definition_slice.rb +1 -0
- data/lib/graphql/language/document_from_schema_definition.rb +9 -10
- data/lib/graphql/language/generation.rb +23 -9
- data/lib/graphql/language/lexer.rb +5 -0
- data/lib/graphql/language/nodes.rb +2094 -419
- data/lib/graphql/language/parser.rb +17 -11
- data/lib/graphql/language/printer.rb +31 -16
- data/lib/graphql/language/sanitized_printer.rb +16 -5
- data/lib/graphql/language/static_visitor.rb +19 -4
- data/lib/graphql/language/visitor.rb +51 -29
- data/lib/graphql/language.rb +13 -7
- data/lib/graphql/load_application_object_failed_error.rb +14 -5
- data/lib/graphql/name_validator.rb +1 -0
- data/lib/graphql/pagination/active_record_relation_connection.rb +1 -0
- data/lib/graphql/pagination/array_connection.rb +20 -6
- data/lib/graphql/pagination/connection.rb +178 -48
- data/lib/graphql/pagination/connections.rb +21 -14
- data/lib/graphql/pagination/mongoid_relation_connection.rb +1 -0
- data/lib/graphql/pagination/relation_connection.rb +118 -21
- data/lib/graphql/pagination/sequel_dataset_connection.rb +1 -0
- data/lib/graphql/pagination.rb +1 -0
- data/lib/graphql/parse_error.rb +1 -0
- data/lib/graphql/query/context/scoped_context.rb +2 -1
- data/lib/graphql/query/context.rb +106 -35
- data/lib/graphql/query/fingerprint.rb +15 -7
- data/lib/graphql/query/input_validation_result.rb +1 -0
- data/lib/graphql/query/null_context.rb +1 -0
- data/lib/graphql/query/partial.rb +28 -15
- data/lib/graphql/query/result.rb +15 -5
- data/lib/graphql/query/validation_pipeline.rb +16 -6
- data/lib/graphql/query/variable_validation_error.rb +1 -0
- data/lib/graphql/query/variables.rb +4 -1
- data/lib/graphql/query.rb +193 -49
- data/lib/graphql/railtie.rb +7 -3
- data/lib/graphql/rake_task/validate.rb +72 -17
- data/lib/graphql/rake_task.rb +55 -23
- data/lib/graphql/relay/range_add.rb +32 -21
- data/lib/graphql/relay.rb +1 -0
- data/lib/graphql/rubocop/graphql/base_cop.rb +1 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +9 -6
- data/lib/graphql/rubocop/graphql/default_required_true.rb +9 -6
- data/lib/graphql/rubocop/graphql/field_type_in_block.rb +12 -8
- data/lib/graphql/rubocop/graphql/root_types_in_block.rb +9 -5
- data/lib/graphql/rubocop.rb +1 -0
- data/lib/graphql/runtime_error.rb +1 -0
- data/lib/graphql/runtime_type_error.rb +1 -0
- data/lib/graphql/schema/addition.rb +18 -6
- data/lib/graphql/schema/always_visible.rb +1 -0
- data/lib/graphql/schema/argument.rb +265 -42
- data/lib/graphql/schema/base_64_encoder.rb +2 -2
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -0
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +2 -2
- data/lib/graphql/schema/build_from_definition.rb +94 -27
- data/lib/graphql/schema/built_in_types.rb +1 -0
- data/lib/graphql/schema/directive/deprecated.rb +1 -0
- data/lib/graphql/schema/directive/feature.rb +39 -22
- data/lib/graphql/schema/directive/flagged.rb +6 -1
- data/lib/graphql/schema/directive/include.rb +1 -0
- data/lib/graphql/schema/directive/one_of.rb +1 -0
- data/lib/graphql/schema/directive/skip.rb +1 -0
- data/lib/graphql/schema/directive/specified_by.rb +1 -0
- data/lib/graphql/schema/directive/transform.rb +17 -8
- data/lib/graphql/schema/directive.rb +12 -7
- data/lib/graphql/schema/enum.rb +99 -38
- data/lib/graphql/schema/enum_value.rb +21 -13
- data/lib/graphql/schema/field/connection_extension.rb +10 -2
- data/lib/graphql/schema/field/scope_extension.rb +1 -0
- data/lib/graphql/schema/field.rb +621 -109
- data/lib/graphql/schema/field_extension.rb +89 -34
- data/lib/graphql/schema/find_inherited_value.rb +5 -3
- data/lib/graphql/schema/finder.rb +22 -8
- data/lib/graphql/schema/has_single_input_argument.rb +39 -6
- data/lib/graphql/schema/input_object.rb +40 -13
- data/lib/graphql/schema/interface.rb +33 -17
- data/lib/graphql/schema/introspection_system.rb +7 -3
- data/lib/graphql/schema/late_bound_type.rb +2 -2
- data/lib/graphql/schema/list.rb +15 -4
- data/lib/graphql/schema/loader.rb +23 -12
- data/lib/graphql/schema/member/base_dsl_methods.rb +58 -12
- data/lib/graphql/schema/member/build_type.rb +16 -5
- data/lib/graphql/schema/member/graphql_type_names.rb +10 -6
- data/lib/graphql/schema/member/has_arguments.rb +115 -48
- data/lib/graphql/schema/member/has_ast_node.rb +1 -0
- data/lib/graphql/schema/member/has_authorization.rb +5 -0
- data/lib/graphql/schema/member/has_dataloader.rb +91 -34
- data/lib/graphql/schema/member/has_deprecation_reason.rb +15 -2
- data/lib/graphql/schema/member/has_directives.rb +38 -10
- data/lib/graphql/schema/member/has_fields.rb +151 -70
- data/lib/graphql/schema/member/has_interfaces.rb +10 -2
- data/lib/graphql/schema/member/has_path.rb +14 -5
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +1 -0
- data/lib/graphql/schema/member/has_validators.rb +19 -4
- data/lib/graphql/schema/member/relay_shortcuts.rb +10 -2
- data/lib/graphql/schema/member/scoped.rb +14 -3
- data/lib/graphql/schema/member/type_system_helpers.rb +36 -6
- data/lib/graphql/schema/member/validates_input.rb +1 -0
- data/lib/graphql/schema/member.rb +9 -2
- data/lib/graphql/schema/mutation.rb +50 -46
- data/lib/graphql/schema/non_null.rb +21 -5
- data/lib/graphql/schema/object.rb +33 -12
- data/lib/graphql/schema/printer.rb +52 -31
- data/lib/graphql/schema/ractor_shareable.rb +6 -2
- data/lib/graphql/schema/relay_classic_mutation.rb +3 -3
- data/lib/graphql/schema/resolver/has_payload_type.rb +29 -7
- data/lib/graphql/schema/resolver.rb +156 -45
- data/lib/graphql/schema/scalar.rb +1 -0
- data/lib/graphql/schema/subscription.rb +67 -28
- data/lib/graphql/schema/timeout.rb +65 -25
- data/lib/graphql/schema/type_expression.rb +14 -5
- data/lib/graphql/schema/type_membership.rb +29 -10
- data/lib/graphql/schema/union.rb +4 -2
- data/lib/graphql/schema/unique_within_type.rb +24 -5
- data/lib/graphql/schema/validator/all_validator.rb +17 -9
- data/lib/graphql/schema/validator/allow_blank_validator.rb +8 -2
- data/lib/graphql/schema/validator/allow_null_validator.rb +8 -2
- data/lib/graphql/schema/validator/exclusion_validator.rb +14 -5
- data/lib/graphql/schema/validator/format_validator.rb +21 -10
- data/lib/graphql/schema/validator/inclusion_validator.rb +15 -6
- data/lib/graphql/schema/validator/length_validator.rb +23 -12
- data/lib/graphql/schema/validator/numericality_validator.rb +29 -16
- data/lib/graphql/schema/validator/required_validator.rb +45 -31
- data/lib/graphql/schema/validator.rb +89 -25
- data/lib/graphql/schema/visibility/migration.rb +14 -7
- data/lib/graphql/schema/visibility/profile.rb +20 -17
- data/lib/graphql/schema/visibility/visit.rb +12 -10
- data/lib/graphql/schema/visibility.rb +24 -20
- data/lib/graphql/schema/warden.rb +117 -31
- data/lib/graphql/schema/wrapper.rb +4 -1
- data/lib/graphql/schema.rb +1046 -300
- data/lib/graphql/static_validation/all_rules.rb +2 -1
- data/lib/graphql/static_validation/base_visitor.rb +48 -8
- data/lib/graphql/static_validation/definition_dependencies.rb +27 -7
- data/lib/graphql/static_validation/error.rb +3 -0
- data/lib/graphql/static_validation/interpreter_visitor.rb +1 -0
- data/lib/graphql/static_validation/literal_validator.rb +1 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +4 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +1 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +3 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +1 -0
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +3 -0
- data/lib/graphql/static_validation/rules/directives_are_defined_error.rb +1 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +3 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +3 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +9 -1
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +295 -134
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +14 -2
- data/lib/graphql/static_validation/rules/fragment_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_named.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_used.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_used_error.rb +1 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +3 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +3 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/not_single_subscription_error.rb +1 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +4 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +1 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid.rb +3 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid_error.rb +1 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +3 -0
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +4 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/subscription_root_exists_and_single_subscription_selection.rb +4 -1
- data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +3 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +3 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +207 -51
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +3 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +6 -3
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb +1 -0
- data/lib/graphql/static_validation/validation_context.rb +3 -2
- data/lib/graphql/static_validation/validation_timeout_error.rb +1 -0
- data/lib/graphql/static_validation/validator.rb +41 -16
- data/lib/graphql/static_validation.rb +1 -0
- data/lib/graphql/string_encoding_error.rb +1 -0
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +85 -65
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +10 -4
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +1 -0
- data/lib/graphql/subscriptions/event.rb +25 -6
- data/lib/graphql/subscriptions/serialize.rb +58 -19
- data/lib/graphql/subscriptions.rb +172 -46
- data/lib/graphql/testing/helpers.rb +17 -4
- data/lib/graphql/testing/mock_action_cable.rb +55 -33
- data/lib/graphql/testing.rb +1 -0
- data/lib/graphql/tracing/active_support_notifications_trace.rb +17 -9
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +2 -1
- data/lib/graphql/tracing/appoptics_trace.rb +2 -1
- data/lib/graphql/tracing/appoptics_tracing.rb +2 -1
- data/lib/graphql/tracing/appsignal_trace.rb +16 -7
- data/lib/graphql/tracing/appsignal_tracing.rb +7 -3
- data/lib/graphql/tracing/call_legacy_tracers.rb +1 -0
- data/lib/graphql/tracing/data_dog_trace.rb +17 -6
- data/lib/graphql/tracing/data_dog_tracing.rb +10 -3
- data/lib/graphql/tracing/detailed_trace/active_record_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace/memory_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace/redis_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace.rb +105 -42
- data/lib/graphql/tracing/legacy_hooks_trace.rb +5 -0
- data/lib/graphql/tracing/legacy_trace.rb +1 -0
- data/lib/graphql/tracing/monitor_trace.rb +17 -11
- data/lib/graphql/tracing/new_relic_trace.rb +17 -8
- data/lib/graphql/tracing/new_relic_tracing.rb +7 -3
- data/lib/graphql/tracing/notifications_trace.rb +11 -8
- data/lib/graphql/tracing/notifications_tracing.rb +23 -7
- data/lib/graphql/tracing/null_trace.rb +1 -0
- data/lib/graphql/tracing/perfetto_trace/trace_pb.rb +1 -0
- data/lib/graphql/tracing/perfetto_trace.rb +41 -19
- data/lib/graphql/tracing/platform_trace.rb +3 -1
- data/lib/graphql/tracing/platform_tracing.rb +16 -7
- data/lib/graphql/tracing/prometheus_trace/graphql_collector.rb +1 -0
- data/lib/graphql/tracing/prometheus_trace.rb +22 -13
- data/lib/graphql/tracing/prometheus_tracing.rb +1 -0
- data/lib/graphql/tracing/scout_trace.rb +10 -4
- data/lib/graphql/tracing/scout_tracing.rb +7 -3
- data/lib/graphql/tracing/sentry_trace.rb +12 -5
- data/lib/graphql/tracing/statsd_trace.rb +12 -6
- data/lib/graphql/tracing/statsd_tracing.rb +7 -1
- data/lib/graphql/tracing/trace.rb +231 -58
- data/lib/graphql/tracing.rb +25 -9
- data/lib/graphql/type_kinds.rb +2 -1
- data/lib/graphql/types/big_int.rb +1 -0
- data/lib/graphql/types/boolean.rb +1 -0
- data/lib/graphql/types/float.rb +1 -0
- data/lib/graphql/types/id.rb +1 -0
- data/lib/graphql/types/int.rb +2 -1
- data/lib/graphql/types/iso_8601_date.rb +21 -4
- data/lib/graphql/types/iso_8601_date_time.rb +33 -6
- data/lib/graphql/types/iso_8601_duration.rb +42 -9
- data/lib/graphql/types/json.rb +1 -0
- data/lib/graphql/types/relay/base_connection.rb +38 -32
- data/lib/graphql/types/relay/base_edge.rb +15 -9
- data/lib/graphql/types/relay/connection_behaviors.rb +19 -3
- data/lib/graphql/types/relay/edge_behaviors.rb +17 -4
- data/lib/graphql/types/relay/has_node_field.rb +6 -1
- data/lib/graphql/types/relay/has_nodes_field.rb +6 -1
- data/lib/graphql/types/relay/node.rb +1 -0
- data/lib/graphql/types/relay/node_behaviors.rb +5 -1
- data/lib/graphql/types/relay/page_info.rb +1 -0
- data/lib/graphql/types/relay/page_info_behaviors.rb +1 -0
- data/lib/graphql/types/relay.rb +4 -3
- data/lib/graphql/types/string.rb +1 -0
- data/lib/graphql/types.rb +1 -0
- data/lib/graphql/unauthorized_enum_value_error.rb +4 -1
- data/lib/graphql/unauthorized_error.rb +11 -4
- data/lib/graphql/unauthorized_field_error.rb +4 -1
- data/lib/graphql/unresolved_type_error.rb +16 -5
- data/lib/graphql/version.rb +2 -1
- data/lib/graphql.rb +37 -9
- data/readme.md +1 -1
- metadata +89 -5
- data/.yardopts +0 -5
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: false
|
|
2
3
|
require "graphql/schema/build_from_definition/resolve_map"
|
|
3
4
|
|
|
4
5
|
module GraphQL
|
|
5
6
|
class Schema
|
|
6
7
|
module BuildFromDefinition
|
|
7
8
|
class << self
|
|
8
|
-
#
|
|
9
|
+
# See [Schema.from_definition](rdoc-ref:Schema.from_definition)
|
|
9
10
|
def from_definition(schema_superclass, definition_string, parser: GraphQL.default_parser, **kwargs)
|
|
10
11
|
if defined?(parser::SchemaParser)
|
|
11
12
|
parser = parser::SchemaParser
|
|
@@ -25,8 +26,9 @@ module GraphQL
|
|
|
25
26
|
end
|
|
26
27
|
end
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
#--
|
|
30
|
+
# @requires_ancestor: Kernel
|
|
31
|
+
module Builder # :nodoc:
|
|
30
32
|
include GraphQL::EmptyObjects
|
|
31
33
|
extend self
|
|
32
34
|
|
|
@@ -53,12 +55,15 @@ module GraphQL
|
|
|
53
55
|
schema_definition = schema_defns.first
|
|
54
56
|
types = {}
|
|
55
57
|
directives = schema_superclass.directives.dup
|
|
56
|
-
|
|
57
|
-
#
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
# Directive applications are queued while types are built, then applied once every type is complete,
|
|
59
|
+
# because applying a directive coerces its arguments, which requires fully-built input types.
|
|
60
|
+
queued_directives = []
|
|
61
|
+
type_resolver = TypeResolver.new(types, directives, queued_directives) { |type_name| types[type_name] ||= Schema::LateBoundType.new(type_name) }
|
|
62
|
+
# Make a different type resolver because directive argument types must be real classes (not late-bound)
|
|
63
|
+
# when queued directives are applied. It builds types eagerly. (Each type registers itself in `types`
|
|
64
|
+
# before building its members, so cycles between input objects terminate.)
|
|
60
65
|
directive_type_resolver = nil
|
|
61
|
-
directive_type_resolver =
|
|
66
|
+
directive_type_resolver = TypeResolver.new(types, directives, queued_directives) { |type_name|
|
|
62
67
|
types[type_name] ||= begin
|
|
63
68
|
defn = document.definitions.find { |d| d.respond_to?(:name) && d.name == type_name }
|
|
64
69
|
if defn
|
|
@@ -69,7 +74,7 @@ module GraphQL
|
|
|
69
74
|
raise "No definition for #{type_name.inspect} found in schema document or built-in types. Add a definition for it or remove it."
|
|
70
75
|
end
|
|
71
76
|
end
|
|
72
|
-
}
|
|
77
|
+
}
|
|
73
78
|
|
|
74
79
|
directives.merge!(GraphQL::Schema.default_directives)
|
|
75
80
|
document.definitions.each do |definition|
|
|
@@ -117,7 +122,7 @@ module GraphQL
|
|
|
117
122
|
end
|
|
118
123
|
end
|
|
119
124
|
|
|
120
|
-
|
|
125
|
+
build_definition_from_node(definition, type_resolver, default_resolve, base_types)
|
|
121
126
|
end
|
|
122
127
|
end
|
|
123
128
|
end
|
|
@@ -185,11 +190,15 @@ module GraphQL
|
|
|
185
190
|
end
|
|
186
191
|
end
|
|
187
192
|
|
|
193
|
+
# All types are built now, so directive arguments can be coerced
|
|
194
|
+
apply_queued_directives(queued_directives)
|
|
195
|
+
|
|
188
196
|
builder = self
|
|
189
197
|
|
|
190
198
|
found_types = types.values
|
|
191
199
|
object_types = found_types.select { |t| t.respond_to?(:kind) && t.kind.object? }
|
|
192
200
|
schema_class = Class.new(schema_superclass) do
|
|
201
|
+
#: self as singleton(GraphQL::Schema)
|
|
193
202
|
begin
|
|
194
203
|
# Add these first so that there's some chance of resolving late-bound types
|
|
195
204
|
add_type_and_traverse(found_types, root: false)
|
|
@@ -228,6 +237,7 @@ module GraphQL
|
|
|
228
237
|
if schema_definition
|
|
229
238
|
ast_node(schema_definition)
|
|
230
239
|
builder.build_directives(self, schema_definition, type_resolver)
|
|
240
|
+
builder.apply_queued_directives(queued_directives)
|
|
231
241
|
end
|
|
232
242
|
|
|
233
243
|
using.each do |plugin, options|
|
|
@@ -262,6 +272,7 @@ module GraphQL
|
|
|
262
272
|
build_directives(schema_class, ext, type_resolver)
|
|
263
273
|
end
|
|
264
274
|
end
|
|
275
|
+
apply_queued_directives(queued_directives)
|
|
265
276
|
|
|
266
277
|
schema_class
|
|
267
278
|
end
|
|
@@ -293,7 +304,13 @@ module GraphQL
|
|
|
293
304
|
# with their actual definitions.
|
|
294
305
|
#
|
|
295
306
|
# (Schema definitions are allowed to reference those built-ins without redefining them.)
|
|
296
|
-
#
|
|
307
|
+
#
|
|
308
|
+
# **Returns**
|
|
309
|
+
#
|
|
310
|
+
# - `Object` — void
|
|
311
|
+
#
|
|
312
|
+
# :call-seq:
|
|
313
|
+
# replace_late_bound_types_with_built_in(types) -> Object
|
|
297
314
|
def replace_late_bound_types_with_built_in(types)
|
|
298
315
|
GraphQL::Schema::BUILT_IN_TYPES.each do |scalar_name, built_in_scalar|
|
|
299
316
|
existing_type = types[scalar_name]
|
|
@@ -303,7 +320,26 @@ module GraphQL
|
|
|
303
320
|
end
|
|
304
321
|
end
|
|
305
322
|
|
|
323
|
+
# Apply `ast_node`'s directives to `definition`. If any of those directives has arguments,
|
|
324
|
+
# they're queued for {apply_queued_directives} because coercing arguments requires fully-built types.
|
|
325
|
+
# Directives without arguments are applied right away, since some (like `@oneOf`) affect how the rest of the type is built.
|
|
306
326
|
def build_directives(definition, ast_node, type_resolver)
|
|
327
|
+
return if ast_node.directives.empty?
|
|
328
|
+
|
|
329
|
+
if ast_node.directives.all? { |dir_node| dir_node.name == "deprecated" || type_resolver.directive_class(dir_node.name)&.all_argument_definitions&.empty? }
|
|
330
|
+
apply_directives(definition, ast_node, type_resolver)
|
|
331
|
+
else
|
|
332
|
+
type_resolver.queued_directives << [definition, ast_node, type_resolver]
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
def apply_queued_directives(queued_directives)
|
|
337
|
+
until queued_directives.empty?
|
|
338
|
+
apply_directives(*queued_directives.shift)
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def apply_directives(definition, ast_node, type_resolver)
|
|
307
343
|
dirs = prepare_directives(ast_node, type_resolver)
|
|
308
344
|
dirs.each do |(dir_class, options)|
|
|
309
345
|
if definition.respond_to?(:schema_directive)
|
|
@@ -354,7 +390,9 @@ module GraphQL
|
|
|
354
390
|
def build_enum_type(enum_type_definition, type_resolver, base_type)
|
|
355
391
|
builder = self
|
|
356
392
|
Class.new(base_type) do
|
|
393
|
+
#: self as singleton(GraphQL::Schema::Enum)
|
|
357
394
|
graphql_name(enum_type_definition.name)
|
|
395
|
+
type_resolver.register(self)
|
|
358
396
|
builder.build_directives(self, enum_type_definition, type_resolver)
|
|
359
397
|
description(enum_type_definition.description)
|
|
360
398
|
ast_node(enum_type_definition)
|
|
@@ -364,13 +402,13 @@ module GraphQL
|
|
|
364
402
|
|
|
365
403
|
def build_values(type_class, enum_value_definitions, type_resolver)
|
|
366
404
|
enum_value_definitions.each do |enum_value_definition|
|
|
367
|
-
type_class.value(enum_value_definition.name,
|
|
405
|
+
enum_value = type_class.value(enum_value_definition.name,
|
|
368
406
|
value: enum_value_definition.name,
|
|
369
407
|
deprecation_reason: build_deprecation_reason(enum_value_definition.directives),
|
|
370
408
|
description: enum_value_definition.description,
|
|
371
|
-
directives: prepare_directives(enum_value_definition, type_resolver),
|
|
372
409
|
ast_node: enum_value_definition,
|
|
373
410
|
)
|
|
411
|
+
build_directives(enum_value, enum_value_definition, type_resolver)
|
|
374
412
|
end
|
|
375
413
|
end
|
|
376
414
|
|
|
@@ -387,7 +425,9 @@ module GraphQL
|
|
|
387
425
|
def build_scalar_type(scalar_type_definition, type_resolver, base_type, default_resolve:)
|
|
388
426
|
builder = self
|
|
389
427
|
Class.new(base_type) do
|
|
428
|
+
#: self as singleton(GraphQL::Schema::Scalar)
|
|
390
429
|
graphql_name(scalar_type_definition.name)
|
|
430
|
+
type_resolver.register(self)
|
|
391
431
|
description(scalar_type_definition.description)
|
|
392
432
|
ast_node(scalar_type_definition)
|
|
393
433
|
builder.build_directives(self, scalar_type_definition, type_resolver)
|
|
@@ -410,7 +450,9 @@ module GraphQL
|
|
|
410
450
|
def build_union_type(union_type_definition, type_resolver, base_type)
|
|
411
451
|
builder = self
|
|
412
452
|
Class.new(base_type) do
|
|
453
|
+
#: self as singleton(GraphQL::Schema::Union)
|
|
413
454
|
graphql_name(union_type_definition.name)
|
|
455
|
+
type_resolver.register(self)
|
|
414
456
|
description(union_type_definition.description)
|
|
415
457
|
possible_types(*union_type_definition.types.map { |type_name| type_resolver.call(type_name) })
|
|
416
458
|
ast_node(union_type_definition)
|
|
@@ -422,7 +464,9 @@ module GraphQL
|
|
|
422
464
|
builder = self
|
|
423
465
|
|
|
424
466
|
Class.new(base_type) do
|
|
467
|
+
#: self as singleton(GraphQL::Schema::Object)
|
|
425
468
|
graphql_name(object_type_definition.name)
|
|
469
|
+
type_resolver.register(self)
|
|
426
470
|
description(object_type_definition.description)
|
|
427
471
|
ast_node(object_type_definition)
|
|
428
472
|
builder.build_directives(self, object_type_definition, type_resolver)
|
|
@@ -440,7 +484,9 @@ module GraphQL
|
|
|
440
484
|
def build_input_object_type(input_object_type_definition, type_resolver, base_type)
|
|
441
485
|
builder = self
|
|
442
486
|
Class.new(base_type) do
|
|
487
|
+
#: self as singleton(GraphQL::Schema::InputObject)
|
|
443
488
|
graphql_name(input_object_type_definition.name)
|
|
489
|
+
type_resolver.register(self)
|
|
444
490
|
description(input_object_type_definition.description)
|
|
445
491
|
ast_node(input_object_type_definition)
|
|
446
492
|
builder.build_directives(self, input_object_type_definition, type_resolver)
|
|
@@ -473,7 +519,7 @@ module GraphQL
|
|
|
473
519
|
EMPTY_HASH
|
|
474
520
|
end
|
|
475
521
|
|
|
476
|
-
type_class.argument(
|
|
522
|
+
argument = type_class.argument(
|
|
477
523
|
argument_defn.name,
|
|
478
524
|
type: type_resolver.call(argument_defn.type),
|
|
479
525
|
required: false,
|
|
@@ -481,9 +527,9 @@ module GraphQL
|
|
|
481
527
|
deprecation_reason: builder.build_deprecation_reason(argument_defn.directives),
|
|
482
528
|
ast_node: argument_defn,
|
|
483
529
|
camelize: false,
|
|
484
|
-
directives: prepare_directives(argument_defn, type_resolver),
|
|
485
530
|
**default_value_kwargs
|
|
486
531
|
)
|
|
532
|
+
builder.build_directives(argument, argument_defn, type_resolver)
|
|
487
533
|
end
|
|
488
534
|
end
|
|
489
535
|
|
|
@@ -502,8 +548,10 @@ module GraphQL
|
|
|
502
548
|
def build_interface_type(interface_type_definition, type_resolver, base_type)
|
|
503
549
|
builder = self
|
|
504
550
|
Module.new do
|
|
551
|
+
#: self as GraphQL::Schema::Member::interface_definition
|
|
505
552
|
include base_type
|
|
506
553
|
graphql_name(interface_type_definition.name)
|
|
554
|
+
type_resolver.register(self)
|
|
507
555
|
description(interface_type_definition.description)
|
|
508
556
|
builder.build_interfaces(self, interface_type_definition.interfaces, type_resolver)
|
|
509
557
|
ast_node(interface_type_definition)
|
|
@@ -528,11 +576,11 @@ module GraphQL
|
|
|
528
576
|
ast_node: field_definition,
|
|
529
577
|
method_conflict_warning: false,
|
|
530
578
|
camelize: false,
|
|
531
|
-
directives: prepare_directives(field_definition, type_resolver),
|
|
532
579
|
resolver_method: resolve_method_name,
|
|
533
580
|
resolve_batch: resolve_method_name,
|
|
534
581
|
)
|
|
535
582
|
|
|
583
|
+
builder.build_directives(schema_field_defn, field_definition, type_resolver)
|
|
536
584
|
builder.build_arguments(schema_field_defn, field_definition.arguments, type_resolver)
|
|
537
585
|
|
|
538
586
|
# Don't do this for interfaces
|
|
@@ -544,6 +592,7 @@ module GraphQL
|
|
|
544
592
|
|
|
545
593
|
def define_field_resolve_method(owner, method_name, field_name)
|
|
546
594
|
owner.define_method(method_name) { |**args|
|
|
595
|
+
#: self as GraphQL::Schema::Object
|
|
547
596
|
field_instance = context.types.field(owner, field_name)
|
|
548
597
|
context.schema.definition_default_resolve.call(self.class, field_instance, object, args, context)
|
|
549
598
|
}
|
|
@@ -555,28 +604,46 @@ module GraphQL
|
|
|
555
604
|
}
|
|
556
605
|
end
|
|
557
606
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
607
|
+
class TypeResolver
|
|
608
|
+
def initialize(lookup_hash, directives, queued_directives, &missing_type_handler)
|
|
609
|
+
@lookup_hash = lookup_hash
|
|
610
|
+
@directives = directives
|
|
611
|
+
@queued_directives = queued_directives
|
|
612
|
+
@missing_type_handler = missing_type_handler
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
# Directive applications waiting for {Builder#apply_queued_directives}
|
|
616
|
+
attr_reader :queued_directives
|
|
617
|
+
|
|
618
|
+
# Add `type` to the lookup hash. Types call this before building their members, so that references back to them (including cycles) find this type.
|
|
619
|
+
def register(type)
|
|
620
|
+
@lookup_hash[type.graphql_name] = type
|
|
621
|
+
end
|
|
622
|
+
|
|
623
|
+
# The already-defined directive class named `name`, or `nil` if there isn't one yet
|
|
624
|
+
def directive_class(name)
|
|
625
|
+
@directives[name]
|
|
626
|
+
end
|
|
627
|
+
|
|
628
|
+
def call(ast_node)
|
|
561
629
|
case ast_node
|
|
562
630
|
when GraphQL::Language::Nodes::TypeName
|
|
563
631
|
type_name = ast_node.name
|
|
564
|
-
if lookup_hash.key?(type_name)
|
|
565
|
-
lookup_hash[type_name]
|
|
632
|
+
if @lookup_hash.key?(type_name)
|
|
633
|
+
@lookup_hash[type_name]
|
|
566
634
|
else
|
|
567
|
-
missing_type_handler.call(type_name)
|
|
635
|
+
@missing_type_handler.call(type_name)
|
|
568
636
|
end
|
|
569
637
|
when GraphQL::Language::Nodes::NonNullType
|
|
570
|
-
|
|
638
|
+
call(ast_node.of_type).to_non_null_type
|
|
571
639
|
when GraphQL::Language::Nodes::ListType
|
|
572
|
-
|
|
640
|
+
call(ast_node.of_type).to_list_type
|
|
573
641
|
when String
|
|
574
|
-
directives[ast_node] ||= missing_type_handler.call(ast_node)
|
|
642
|
+
@directives[ast_node] ||= @missing_type_handler.call(ast_node)
|
|
575
643
|
else
|
|
576
644
|
raise "Unexpected ast_node: #{ast_node.inspect}"
|
|
577
645
|
end
|
|
578
|
-
|
|
579
|
-
resolve_type_proc
|
|
646
|
+
end
|
|
580
647
|
end
|
|
581
648
|
end
|
|
582
649
|
|
|
@@ -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
|
|
@@ -127,10 +128,14 @@ module GraphQL
|
|
|
127
128
|
end
|
|
128
129
|
end
|
|
129
130
|
|
|
130
|
-
#
|
|
131
|
+
# **Returns**
|
|
132
|
+
#
|
|
133
|
+
# - `GraphQL::Schema::Field, GraphQL::Schema::Argument, Class, Module`
|
|
131
134
|
attr_reader :owner
|
|
132
135
|
|
|
133
|
-
#
|
|
136
|
+
# **Returns**
|
|
137
|
+
#
|
|
138
|
+
# - `GraphQL::Interpreter::Arguments`
|
|
134
139
|
attr_reader :arguments
|
|
135
140
|
|
|
136
141
|
class InvalidArgumentError < GraphQL::Error
|