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,8 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
5
6
|
class Member
|
|
7
|
+
#--
|
|
8
|
+
# @requires_ancestor: Kernel
|
|
6
9
|
module TypeSystemHelpers
|
|
7
10
|
def initialize(...)
|
|
8
11
|
super
|
|
@@ -10,7 +13,12 @@ module GraphQL
|
|
|
10
13
|
@to_list_type ||= nil
|
|
11
14
|
end
|
|
12
15
|
|
|
13
|
-
#
|
|
16
|
+
# **Returns**
|
|
17
|
+
#
|
|
18
|
+
# - `Schema::NonNull` — Make a non-null-type representation of this type
|
|
19
|
+
#
|
|
20
|
+
# :call-seq:
|
|
21
|
+
# to_non_null_type() -> Schema::NonNull
|
|
14
22
|
def to_non_null_type
|
|
15
23
|
@to_non_null_type || begin
|
|
16
24
|
t = GraphQL::Schema::NonNull.new(self)
|
|
@@ -22,7 +30,12 @@ module GraphQL
|
|
|
22
30
|
end
|
|
23
31
|
end
|
|
24
32
|
|
|
25
|
-
#
|
|
33
|
+
# **Returns**
|
|
34
|
+
#
|
|
35
|
+
# - `Schema::List` — Make a list-type representation of this type
|
|
36
|
+
#
|
|
37
|
+
# :call-seq:
|
|
38
|
+
# to_list_type() -> Schema::List
|
|
26
39
|
def to_list_type
|
|
27
40
|
@to_list_type || begin
|
|
28
41
|
t = GraphQL::Schema::List.new(self)
|
|
@@ -34,21 +47,38 @@ module GraphQL
|
|
|
34
47
|
end
|
|
35
48
|
end
|
|
36
49
|
|
|
37
|
-
#
|
|
50
|
+
# **Returns**
|
|
51
|
+
#
|
|
52
|
+
# - `Boolean` — true if this is a non-nullable type. A nullable list of non-nullables is considered nullable.
|
|
53
|
+
#
|
|
54
|
+
# :call-seq:
|
|
55
|
+
# non_null?() -> bool
|
|
38
56
|
def non_null?
|
|
39
57
|
false
|
|
40
58
|
end
|
|
41
59
|
|
|
42
|
-
#
|
|
60
|
+
# **Returns**
|
|
61
|
+
#
|
|
62
|
+
# - `Boolean` — true if this is a list type. A non-nullable list is considered a list.
|
|
63
|
+
#
|
|
64
|
+
# :call-seq:
|
|
65
|
+
# list?() -> bool
|
|
43
66
|
def list?
|
|
44
67
|
false
|
|
45
68
|
end
|
|
46
69
|
|
|
47
70
|
def to_type_signature
|
|
48
|
-
graphql_name
|
|
71
|
+
# Each host provides `graphql_name`, but they have no common ancestor
|
|
72
|
+
member = self #: untyped
|
|
73
|
+
member.graphql_name
|
|
49
74
|
end
|
|
50
75
|
|
|
51
|
-
#
|
|
76
|
+
# **Returns**
|
|
77
|
+
#
|
|
78
|
+
# - `GraphQL::TypeKinds::TypeKind`
|
|
79
|
+
#
|
|
80
|
+
# :call-seq:
|
|
81
|
+
# kind() -> GraphQL::TypeKinds::TypeKind
|
|
52
82
|
def kind
|
|
53
83
|
raise GraphQL::RequiredImplementationMissingError, "No `.kind` defined for #{self}"
|
|
54
84
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require 'graphql/schema/member/base_dsl_methods'
|
|
3
4
|
require 'graphql/schema/member/graphql_type_names'
|
|
4
5
|
require 'graphql/schema/member/has_ast_node'
|
|
@@ -20,8 +21,14 @@ module GraphQL
|
|
|
20
21
|
# The base class for things that make up the schema,
|
|
21
22
|
# eg objects, enums, scalars.
|
|
22
23
|
#
|
|
23
|
-
#
|
|
24
|
-
|
|
24
|
+
class Member # :nodoc:
|
|
25
|
+
# A module that defines a GraphQL interface type (it includes `GraphQL::Schema::Interface`).
|
|
26
|
+
#: type interface_definition = GraphQL::Schema::Interface::DefinitionMethods & Module
|
|
27
|
+
|
|
28
|
+
# A class or module that defines a GraphQL type:
|
|
29
|
+
# an object, union, enum, scalar or input object class, or an interface module.
|
|
30
|
+
#: type type_definition = singleton(GraphQL::Schema::Member) | interface_definition
|
|
31
|
+
|
|
25
32
|
include GraphQLTypeNames
|
|
26
33
|
extend BaseDSLMethods
|
|
27
34
|
extend BaseDSLMethods::ConfigurationExtension
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
@@ -8,62 +9,65 @@ module GraphQL
|
|
|
8
9
|
# If you want to customize how this class generates types, in your base class,
|
|
9
10
|
# override the various `generate_*` methods.
|
|
10
11
|
#
|
|
11
|
-
#
|
|
12
|
+
# See [GraphQL::Schema::RelayClassicMutation](rdoc-ref:GraphQL::Schema::RelayClassicMutation) for an extension of this class with some conventions built-in.
|
|
12
13
|
#
|
|
13
|
-
#
|
|
14
|
-
# # Define the mutation:
|
|
15
|
-
# class Mutations::CreateComment < GraphQL::Schema::Mutation
|
|
16
|
-
# argument :body, String, required: true
|
|
17
|
-
# argument :post_id, ID, required: true
|
|
14
|
+
# **Examples**
|
|
18
15
|
#
|
|
19
|
-
#
|
|
20
|
-
# field :errors, [String], null: false
|
|
16
|
+
# **Example: Creating a comment**
|
|
21
17
|
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
# {
|
|
28
|
-
# comment: comment,
|
|
29
|
-
# errors: [],
|
|
30
|
-
# }
|
|
31
|
-
# else
|
|
32
|
-
# # Failed save, return the errors to the client
|
|
33
|
-
# {
|
|
34
|
-
# comment: nil,
|
|
35
|
-
# errors: comment.errors.full_messages
|
|
36
|
-
# }
|
|
37
|
-
# end
|
|
38
|
-
# end
|
|
39
|
-
# end
|
|
18
|
+
# ```ruby
|
|
19
|
+
# # Define the mutation:
|
|
20
|
+
# class Mutations::CreateComment < GraphQL::Schema::Mutation
|
|
21
|
+
# argument :body, String, required: true
|
|
22
|
+
# argument :post_id, ID, required: true
|
|
40
23
|
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
# field :create_comment, mutation: Mutations::CreateComment
|
|
44
|
-
# end
|
|
24
|
+
# field :comment, Types::Comment, null: true
|
|
25
|
+
# field :errors, [String], null: false
|
|
45
26
|
#
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
#
|
|
27
|
+
# def resolve(body:, post_id:)
|
|
28
|
+
# post = Post.find(post_id)
|
|
29
|
+
# comment = post.comments.build(body: body, author: context[:current_user])
|
|
30
|
+
# if comment.save
|
|
31
|
+
# # Successful creation, return the created object with no errors
|
|
32
|
+
# {
|
|
33
|
+
# comment: comment,
|
|
34
|
+
# errors: [],
|
|
35
|
+
# }
|
|
36
|
+
# else
|
|
37
|
+
# # Failed save, return the errors to the client
|
|
38
|
+
# {
|
|
39
|
+
# comment: nil,
|
|
40
|
+
# errors: comment.errors.full_messages
|
|
41
|
+
# }
|
|
42
|
+
# end
|
|
43
|
+
# end
|
|
44
|
+
# end
|
|
60
45
|
#
|
|
46
|
+
# # Hook it up to your mutation:
|
|
47
|
+
# class Types::Mutation < GraphQL::Schema::Object
|
|
48
|
+
# field :create_comment, mutation: Mutations::CreateComment
|
|
49
|
+
# end
|
|
50
|
+
#
|
|
51
|
+
# # Call it from GraphQL:
|
|
52
|
+
# result = MySchema.execute <<-GRAPHQL
|
|
53
|
+
# mutation {
|
|
54
|
+
# createComment(postId: "1", body: "Nice Post!") {
|
|
55
|
+
# errors
|
|
56
|
+
# comment {
|
|
57
|
+
# body
|
|
58
|
+
# author {
|
|
59
|
+
# login
|
|
60
|
+
# }
|
|
61
|
+
# }
|
|
62
|
+
# }
|
|
63
|
+
# }
|
|
64
|
+
# GRAPHQL
|
|
65
|
+
# ```
|
|
61
66
|
class Mutation < GraphQL::Schema::Resolver
|
|
62
67
|
extend GraphQL::Schema::Member::HasFields
|
|
63
68
|
extend GraphQL::Schema::Resolver::HasPayloadType
|
|
64
69
|
|
|
65
|
-
#
|
|
66
|
-
def call_resolve(_args_hash)
|
|
70
|
+
def call_resolve(_args_hash) # :nodoc:
|
|
67
71
|
# Clear any cached values from `loads` or authorization:
|
|
68
72
|
dataloader.clear_cache
|
|
69
73
|
super
|
|
@@ -1,24 +1,40 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
5
6
|
# Represents a non null type in the schema.
|
|
6
|
-
# Wraps a
|
|
7
|
-
#
|
|
7
|
+
# Wraps a [Schema::Member](rdoc-ref:Schema::Member) when it is required.
|
|
8
|
+
# See [Schema::Member::TypeSystemHelpers#to_non_null_type](rdoc-ref:Schema::Member::TypeSystemHelpers#to_non_null_type)
|
|
8
9
|
class NonNull < GraphQL::Schema::Wrapper
|
|
9
10
|
include Schema::Member::ValidatesInput
|
|
10
11
|
|
|
11
|
-
#
|
|
12
|
+
# **Returns**
|
|
13
|
+
#
|
|
14
|
+
# - `GraphQL::TypeKinds::NON_NULL`
|
|
15
|
+
#
|
|
16
|
+
# :call-seq:
|
|
17
|
+
# kind() -> GraphQL::TypeKinds::NON_NULL
|
|
12
18
|
def kind
|
|
13
19
|
GraphQL::TypeKinds::NON_NULL
|
|
14
20
|
end
|
|
15
21
|
|
|
16
|
-
#
|
|
22
|
+
# **Returns**
|
|
23
|
+
#
|
|
24
|
+
# - `true`
|
|
25
|
+
#
|
|
26
|
+
# :call-seq:
|
|
27
|
+
# non_null?() -> true
|
|
17
28
|
def non_null?
|
|
18
29
|
true
|
|
19
30
|
end
|
|
20
31
|
|
|
21
|
-
#
|
|
32
|
+
# **Returns**
|
|
33
|
+
#
|
|
34
|
+
# - `Boolean` — True if this type wraps a list type
|
|
35
|
+
#
|
|
36
|
+
# :call-seq:
|
|
37
|
+
# list?() -> bool
|
|
22
38
|
def list?
|
|
23
39
|
@of_type.list?
|
|
24
40
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
require "graphql/query/null_context"
|
|
4
5
|
|
|
@@ -18,13 +19,22 @@ module GraphQL
|
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
|
|
21
|
-
#
|
|
22
|
+
# **Returns**
|
|
23
|
+
#
|
|
24
|
+
# - `Object` — the application object this type is wrapping
|
|
22
25
|
attr_reader :object
|
|
23
26
|
|
|
24
|
-
#
|
|
27
|
+
# **Returns**
|
|
28
|
+
#
|
|
29
|
+
# - `GraphQL::Query::Context` — the context instance for this query
|
|
25
30
|
attr_reader :context
|
|
26
31
|
|
|
27
|
-
#
|
|
32
|
+
# **Returns**
|
|
33
|
+
#
|
|
34
|
+
# - `GraphQL::Dataloader`
|
|
35
|
+
#
|
|
36
|
+
# :call-seq:
|
|
37
|
+
# dataloader() -> GraphQL::Dataloader
|
|
28
38
|
def dataloader
|
|
29
39
|
context.dataloader
|
|
30
40
|
end
|
|
@@ -36,8 +46,8 @@ module GraphQL
|
|
|
36
46
|
end
|
|
37
47
|
|
|
38
48
|
class << self
|
|
39
|
-
# This is protected so that we can be sure callers use the public method,
|
|
40
|
-
#
|
|
49
|
+
# This is protected so that we can be sure callers use the public method, [.authorized_new](rdoc-ref:.authorized_new)
|
|
50
|
+
# See [authorized_new](rdoc-ref:authorized_new) to make instances
|
|
41
51
|
protected :new
|
|
42
52
|
|
|
43
53
|
def wrap_scoped(object, context)
|
|
@@ -54,18 +64,29 @@ module GraphQL
|
|
|
54
64
|
#
|
|
55
65
|
# Probably only the framework should call this method.
|
|
56
66
|
#
|
|
57
|
-
# This might return a
|
|
67
|
+
# This might return a [GraphQL::Execution::Lazy](rdoc-ref:GraphQL::Execution::Lazy) if the user-provided `.authorized?`
|
|
58
68
|
# hook returns some lazy value (like a Promise).
|
|
59
69
|
#
|
|
60
|
-
# The reason that the auth check is in this wrapper method instead of
|
|
70
|
+
# The reason that the auth check is in this wrapper method instead of [.new](rdoc-ref:.new) is because
|
|
61
71
|
# of how it might return a Promise. It would be weird if `.new` returned a promise;
|
|
62
|
-
# It would be a headache to try to maintain Promise-y state inside a
|
|
72
|
+
# It would be a headache to try to maintain Promise-y state inside a [Schema::Object](rdoc-ref:Schema::Object)
|
|
63
73
|
# instance. So, hopefully this wrapper method will do the job.
|
|
64
74
|
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
#
|
|
75
|
+
# **Parameters**
|
|
76
|
+
#
|
|
77
|
+
# - `object` (`Object`) — The thing wrapped by this object
|
|
78
|
+
# - `context` (`GraphQL::Query::Context`)
|
|
79
|
+
#
|
|
80
|
+
# **Returns**
|
|
81
|
+
#
|
|
82
|
+
# - `GraphQL::Schema::Object, GraphQL::Execution::Lazy`
|
|
83
|
+
#
|
|
84
|
+
# **Raises**
|
|
85
|
+
#
|
|
86
|
+
# - `GraphQL::UnauthorizedError` — if the user-provided hook returns `false`
|
|
87
|
+
#
|
|
88
|
+
# :call-seq:
|
|
89
|
+
# authorized_new(Object object, GraphQL::Query::Context context) -> GraphQL::Schema::Object | GraphQL::Execution::Lazy | GraphQL::UnauthorizedError
|
|
69
90
|
def authorized_new(object, context)
|
|
70
91
|
context.query.current_trace.begin_authorized(self, object, context)
|
|
71
92
|
begin
|
|
@@ -1,42 +1,58 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Schema
|
|
4
|
-
# Used to convert your
|
|
5
|
+
# Used to convert your [GraphQL::Schema](rdoc-ref:GraphQL::Schema) to a GraphQL schema string
|
|
5
6
|
#
|
|
6
|
-
#
|
|
7
|
-
# puts GraphQL::Schema::Printer.print_schema(MySchema)
|
|
7
|
+
# **Examples**
|
|
8
8
|
#
|
|
9
|
-
#
|
|
10
|
-
# puts GraphQL::Schema::Printer.new(MySchema).print_schema
|
|
9
|
+
# **Example: print your schema to standard output (via helper)**
|
|
11
10
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
11
|
+
# ```ruby
|
|
12
|
+
# puts GraphQL::Schema::Printer.print_schema(MySchema)
|
|
13
|
+
# ```
|
|
15
14
|
#
|
|
16
|
-
#
|
|
17
|
-
# end
|
|
15
|
+
# **Example: print your schema to standard output**
|
|
18
16
|
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
17
|
+
# ```ruby
|
|
18
|
+
# puts GraphQL::Schema::Printer.new(MySchema).print_schema
|
|
19
|
+
# ```
|
|
21
20
|
#
|
|
22
|
-
#
|
|
23
|
-
# field :title, String, null: false
|
|
24
|
-
# field :body, String, null: false
|
|
25
|
-
# end
|
|
21
|
+
# **Example: print a single type to standard output**
|
|
26
22
|
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
23
|
+
# ```ruby
|
|
24
|
+
# class Types::Query < GraphQL::Schema::Object
|
|
25
|
+
# description "The query root of this schema"
|
|
30
26
|
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
27
|
+
# field :post, Types::Post, null: true
|
|
28
|
+
# end
|
|
33
29
|
#
|
|
30
|
+
# class Types::Post < GraphQL::Schema::Object
|
|
31
|
+
# description "A blog post"
|
|
32
|
+
#
|
|
33
|
+
# field :id, ID, null: false
|
|
34
|
+
# field :title, String, null: false
|
|
35
|
+
# field :body, String, null: false
|
|
36
|
+
# end
|
|
37
|
+
#
|
|
38
|
+
# class MySchema < GraphQL::Schema
|
|
39
|
+
# query(Types::Query)
|
|
40
|
+
# end
|
|
41
|
+
#
|
|
42
|
+
# printer = GraphQL::Schema::Printer.new(MySchema)
|
|
43
|
+
# puts printer.print_type(Types::Post)
|
|
44
|
+
# ```
|
|
34
45
|
class Printer < GraphQL::Language::Printer
|
|
35
46
|
attr_reader :schema, :warden
|
|
36
47
|
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
48
|
+
# **Parameters**
|
|
49
|
+
#
|
|
50
|
+
# - `schema` (`GraphQL::Schema`)
|
|
51
|
+
# - `context` (`Hash`)
|
|
52
|
+
# - `introspection` (`Boolean`) — Should include the introspection types in the string?
|
|
53
|
+
#
|
|
54
|
+
# :call-seq:
|
|
55
|
+
# initialize(GraphQL::Schema schema, Hash context:, bool introspection:)
|
|
40
56
|
def initialize(schema, context: nil, introspection: false)
|
|
41
57
|
@document_from_schema = GraphQL::Language::DocumentFromSchemaDefinition.new(
|
|
42
58
|
schema,
|
|
@@ -53,9 +69,8 @@ module GraphQL
|
|
|
53
69
|
query_root = Class.new(GraphQL::Schema::Object) do
|
|
54
70
|
graphql_name "Root"
|
|
55
71
|
field :throwaway_field, String
|
|
56
|
-
def self.visible
|
|
57
|
-
|
|
58
|
-
end
|
|
72
|
+
# Not `def self.visible?`: Sorbet would treat it as a definition of `Printer.visible?`
|
|
73
|
+
define_singleton_method(:visible?) { |ctx| false }
|
|
59
74
|
end
|
|
60
75
|
schema = Class.new(GraphQL::Schema) {
|
|
61
76
|
query(query_root)
|
|
@@ -75,10 +90,16 @@ module GraphQL
|
|
|
75
90
|
end
|
|
76
91
|
|
|
77
92
|
# Return a GraphQL schema string for the defined types in the schema
|
|
78
|
-
#
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
#
|
|
93
|
+
#
|
|
94
|
+
# **Parameters**
|
|
95
|
+
#
|
|
96
|
+
# - `schema` (`GraphQL::Schema`)
|
|
97
|
+
# - `context` (`Hash`)
|
|
98
|
+
# - `only` (`<#call(member, ctx)>`)
|
|
99
|
+
# - `except` (`<#call(member, ctx)>`)
|
|
100
|
+
#
|
|
101
|
+
# :call-seq:
|
|
102
|
+
# print_schema(GraphQL::Schema schema, **args)
|
|
82
103
|
def self.print_schema(schema, **args)
|
|
83
104
|
printer = new(schema, **args)
|
|
84
105
|
printer.print_schema
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Schema
|
|
4
5
|
module RactorShareable
|
|
@@ -7,6 +8,8 @@ module GraphQL
|
|
|
7
8
|
schema_class.freeze_schema
|
|
8
9
|
end
|
|
9
10
|
|
|
11
|
+
#--
|
|
12
|
+
# @requires_ancestor: singleton(GraphQL::Schema)
|
|
10
13
|
module SchemaExtension
|
|
11
14
|
|
|
12
15
|
def freeze_error_handlers(handlers)
|
|
@@ -25,7 +28,7 @@ module GraphQL
|
|
|
25
28
|
default_logger
|
|
26
29
|
freeze_error_handlers(error_handlers)
|
|
27
30
|
# TODO: this freezes errors of parent classes which could cause trouble
|
|
28
|
-
parent_class = superclass
|
|
31
|
+
parent_class = superclass #: untyped
|
|
29
32
|
while parent_class.respond_to?(:error_handlers)
|
|
30
33
|
freeze_error_handlers(parent_class.error_handlers)
|
|
31
34
|
parent_class = parent_class.superclass
|
|
@@ -58,7 +61,8 @@ module GraphQL
|
|
|
58
61
|
extend(FrozenMethods)
|
|
59
62
|
|
|
60
63
|
Ractor.make_shareable(self)
|
|
61
|
-
superclass
|
|
64
|
+
parent_class = superclass #: untyped
|
|
65
|
+
parent_class.respond_to?(:freeze_schema) && parent_class.freeze_schema
|
|
62
66
|
end
|
|
63
67
|
|
|
64
68
|
module FrozenMethods
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
@@ -17,8 +18,7 @@ module GraphQL
|
|
|
17
18
|
# - using a single `input:` argument makes it easy to post whole JSON objects to the mutation
|
|
18
19
|
# using one GraphQL variable (`$input`) instead of making a separate variable for each argument.
|
|
19
20
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
21
|
+
# See [GraphQL::Schema::Mutation](rdoc-ref:GraphQL::Schema::Mutation) for an example, it's basically the same.
|
|
22
22
|
class RelayClassicMutation < GraphQL::Schema::Mutation
|
|
23
23
|
include GraphQL::Schema::HasSingleInputArgument
|
|
24
24
|
|
|
@@ -29,7 +29,7 @@ module GraphQL
|
|
|
29
29
|
# Relay classic default:
|
|
30
30
|
null(true)
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
# Override [resolve_with_support](rdoc-ref:#resolve_with_support) to
|
|
33
33
|
# delete `client_mutation_id` from the kwargs.
|
|
34
34
|
def resolve_with_support(**inputs)
|
|
35
35
|
input = inputs[:input].to_kwargs
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
@@ -7,12 +8,24 @@ module GraphQL
|
|
|
7
8
|
# generate payload types.
|
|
8
9
|
#
|
|
9
10
|
# Or, an already-defined one can be attached with `payload_type(...)`.
|
|
11
|
+
#--
|
|
12
|
+
# @requires_ancestor: singleton(GraphQL::Schema::Resolver)
|
|
13
|
+
# @requires_ancestor: GraphQL::Schema::Member::HasFields
|
|
10
14
|
module HasPayloadType
|
|
11
15
|
# Call this method to get the derived return type of the mutation,
|
|
12
16
|
# or use it as a configuration method to assign a return type
|
|
13
17
|
# instead of generating one.
|
|
14
|
-
#
|
|
15
|
-
#
|
|
18
|
+
#
|
|
19
|
+
# **Parameters**
|
|
20
|
+
#
|
|
21
|
+
# - `new_payload_type` (`Class, nil`) — If a type definition class is provided, it will be used as the return type of the mutation field
|
|
22
|
+
#
|
|
23
|
+
# **Returns**
|
|
24
|
+
#
|
|
25
|
+
# - `Class` — The object type which this mutation returns.
|
|
26
|
+
#
|
|
27
|
+
# :call-seq:
|
|
28
|
+
# payload_type(Class | nil new_payload_type) -> Class
|
|
16
29
|
def payload_type(new_payload_type = nil)
|
|
17
30
|
if new_payload_type
|
|
18
31
|
@payload_type = new_payload_type
|
|
@@ -44,8 +57,17 @@ module GraphQL
|
|
|
44
57
|
end
|
|
45
58
|
|
|
46
59
|
# An object class to use for deriving return types
|
|
47
|
-
#
|
|
48
|
-
#
|
|
60
|
+
#
|
|
61
|
+
# **Parameters**
|
|
62
|
+
#
|
|
63
|
+
# - `new_class` (`Class, nil`) — Defaults to [GraphQL::Schema::Object](rdoc-ref:GraphQL::Schema::Object)
|
|
64
|
+
#
|
|
65
|
+
# **Returns**
|
|
66
|
+
#
|
|
67
|
+
# - `Class`
|
|
68
|
+
#
|
|
69
|
+
# :call-seq:
|
|
70
|
+
# object_class(Class | nil new_class) -> Class
|
|
49
71
|
def object_class(new_class = nil)
|
|
50
72
|
if new_class
|
|
51
73
|
if defined?(@payload_type)
|
|
@@ -83,13 +105,13 @@ module GraphQL
|
|
|
83
105
|
|
|
84
106
|
private
|
|
85
107
|
|
|
86
|
-
# Build a subclass of
|
|
87
|
-
# This value will be cached as
|
|
108
|
+
# Build a subclass of [.object_class](rdoc-ref:.object_class) based on `self`.
|
|
109
|
+
# This value will be cached as [.payload_type](rdoc-ref:.payload_type).
|
|
88
110
|
# Override this hook to customize return type generation.
|
|
89
111
|
def generate_payload_type
|
|
90
112
|
resolver_name = graphql_name
|
|
91
113
|
resolver_fields = all_field_definitions
|
|
92
|
-
pt = Class.new(object_class)
|
|
114
|
+
pt = Class.new(object_class) #: as singleton(GraphQL::Schema::Object)
|
|
93
115
|
pt.graphql_name("#{resolver_name}Payload")
|
|
94
116
|
pt.description("Autogenerated return type of #{resolver_name}.")
|
|
95
117
|
resolver_fields.each do |f|
|