graphql 2.6.11 → 2.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rdoc_options +4 -0
- data/lib/generators/graphql/core.rb +1 -0
- data/lib/generators/graphql/detailed_trace_generator.rb +1 -0
- data/lib/generators/graphql/enum_generator.rb +1 -0
- data/lib/generators/graphql/field_extractor.rb +1 -0
- data/lib/generators/graphql/input_generator.rb +1 -0
- data/lib/generators/graphql/install/mutation_root_generator.rb +1 -0
- data/lib/generators/graphql/install_generator.rb +1 -0
- data/lib/generators/graphql/interface_generator.rb +1 -0
- data/lib/generators/graphql/loader_generator.rb +8 -2
- data/lib/generators/graphql/mutation_create_generator.rb +8 -2
- data/lib/generators/graphql/mutation_delete_generator.rb +8 -2
- data/lib/generators/graphql/mutation_generator.rb +8 -2
- data/lib/generators/graphql/mutation_update_generator.rb +8 -2
- data/lib/generators/graphql/object_generator.rb +1 -0
- data/lib/generators/graphql/orm_mutations_base.rb +8 -2
- data/lib/generators/graphql/relay.rb +1 -0
- data/lib/generators/graphql/relay_generator.rb +1 -0
- data/lib/generators/graphql/scalar_generator.rb +1 -0
- data/lib/generators/graphql/type_generator.rb +38 -8
- data/lib/generators/graphql/union_generator.rb +1 -0
- data/lib/graphql/analysis/analyzer.rb +35 -9
- data/lib/graphql/analysis/field_usage.rb +1 -0
- data/lib/graphql/analysis/max_query_complexity.rb +2 -1
- data/lib/graphql/analysis/max_query_depth.rb +1 -0
- data/lib/graphql/analysis/query_complexity.rb +57 -20
- data/lib/graphql/analysis/query_depth.rb +17 -12
- data/lib/graphql/analysis/visitor.rb +79 -16
- data/lib/graphql/analysis.rb +23 -6
- data/lib/graphql/analysis_error.rb +1 -0
- data/lib/graphql/autoload.rb +30 -7
- data/lib/graphql/backtrace/table.rb +21 -5
- data/lib/graphql/backtrace/traced_error.rb +8 -3
- data/lib/graphql/backtrace.rb +14 -9
- data/lib/graphql/coercion_error.rb +1 -0
- data/lib/graphql/current.rb +44 -19
- data/lib/graphql/dashboard/application_controller.rb +1 -0
- data/lib/graphql/dashboard/detailed_traces.rb +1 -0
- data/lib/graphql/dashboard/installable.rb +1 -0
- data/lib/graphql/dashboard/landings_controller.rb +1 -0
- data/lib/graphql/dashboard/limiters.rb +1 -0
- data/lib/graphql/dashboard/operation_store.rb +1 -0
- data/lib/graphql/dashboard/statics_controller.rb +1 -0
- data/lib/graphql/dashboard/subscriptions.rb +1 -0
- data/lib/graphql/dashboard.rb +36 -22
- data/lib/graphql/dataloader/active_record_association_source.rb +1 -0
- data/lib/graphql/dataloader/active_record_source.rb +1 -0
- data/lib/graphql/dataloader/async_dataloader.rb +10 -7
- data/lib/graphql/dataloader/null_dataloader.rb +4 -3
- data/lib/graphql/dataloader/request.rb +8 -2
- data/lib/graphql/dataloader/request_all.rb +8 -2
- data/lib/graphql/dataloader/source.rb +127 -35
- data/lib/graphql/dataloader.rb +93 -42
- data/lib/graphql/date_encoding_error.rb +2 -1
- data/lib/graphql/dig.rb +12 -3
- data/lib/graphql/duration_encoding_error.rb +2 -1
- data/lib/graphql/execution/directive_checks.rb +8 -3
- data/lib/graphql/execution/errors.rb +20 -6
- data/lib/graphql/execution/field_resolve_step.rb +40 -13
- data/lib/graphql/execution/finalize.rb +12 -6
- data/lib/graphql/execution/input_values.rb +2 -1
- data/lib/graphql/execution/interpreter/argument_value.rb +17 -5
- data/lib/graphql/execution/interpreter/arguments.rb +24 -9
- data/lib/graphql/execution/interpreter/arguments_cache.rb +2 -1
- data/lib/graphql/execution/interpreter/execution_errors.rb +1 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +1 -0
- data/lib/graphql/execution/interpreter/resolve.rb +18 -8
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +4 -1
- data/lib/graphql/execution/interpreter/runtime.rb +72 -25
- data/lib/graphql/execution/interpreter.rb +15 -6
- data/lib/graphql/execution/lazy/lazy_method_map.rb +21 -8
- data/lib/graphql/execution/lazy.rb +34 -10
- data/lib/graphql/execution/load_argument_step.rb +1 -0
- data/lib/graphql/execution/lookahead.rb +137 -54
- data/lib/graphql/execution/multiplex.rb +4 -4
- data/lib/graphql/execution/next.rb +7 -0
- data/lib/graphql/execution/prepare_object_step.rb +1 -0
- data/lib/graphql/execution/resolve_type_step.rb +2 -1
- data/lib/graphql/execution/runner.rb +9 -3
- data/lib/graphql/execution/selections_step.rb +3 -2
- data/lib/graphql/execution.rb +2 -2
- data/lib/graphql/execution_error.rb +19 -10
- data/lib/graphql/float_decoding_error.rb +1 -0
- data/lib/graphql/float_encoding_error.rb +7 -2
- data/lib/graphql/integer_decoding_error.rb +2 -1
- data/lib/graphql/integer_encoding_error.rb +8 -3
- data/lib/graphql/introspection/base_object.rb +3 -1
- data/lib/graphql/introspection/directive_location_enum.rb +1 -0
- data/lib/graphql/introspection/directive_type.rb +1 -0
- data/lib/graphql/introspection/dynamic_fields.rb +1 -0
- data/lib/graphql/introspection/entry_points.rb +1 -0
- data/lib/graphql/introspection/enum_value_type.rb +1 -0
- data/lib/graphql/introspection/field_type.rb +1 -0
- data/lib/graphql/introspection/input_value_type.rb +1 -0
- data/lib/graphql/introspection/introspection_query.rb +1 -0
- data/lib/graphql/introspection/schema_type.rb +1 -0
- data/lib/graphql/introspection/type_kind_enum.rb +1 -0
- data/lib/graphql/introspection/type_type.rb +1 -0
- data/lib/graphql/introspection.rb +1 -0
- data/lib/graphql/invalid_name_error.rb +1 -0
- data/lib/graphql/invalid_null_error.rb +19 -6
- data/lib/graphql/language/block_string.rb +2 -1
- data/lib/graphql/language/cache.rb +10 -4
- data/lib/graphql/language/comment.rb +1 -0
- data/lib/graphql/language/definition_slice.rb +1 -0
- data/lib/graphql/language/document_from_schema_definition.rb +9 -10
- data/lib/graphql/language/generation.rb +23 -9
- data/lib/graphql/language/lexer.rb +5 -0
- data/lib/graphql/language/nodes.rb +2094 -419
- data/lib/graphql/language/parser.rb +24 -17
- data/lib/graphql/language/printer.rb +31 -16
- data/lib/graphql/language/sanitized_printer.rb +16 -5
- data/lib/graphql/language/static_visitor.rb +19 -4
- data/lib/graphql/language/visitor.rb +51 -29
- data/lib/graphql/language.rb +13 -7
- data/lib/graphql/load_application_object_failed_error.rb +14 -5
- data/lib/graphql/name_validator.rb +1 -0
- data/lib/graphql/pagination/active_record_relation_connection.rb +1 -0
- data/lib/graphql/pagination/array_connection.rb +20 -6
- data/lib/graphql/pagination/connection.rb +178 -48
- data/lib/graphql/pagination/connections.rb +21 -14
- data/lib/graphql/pagination/mongoid_relation_connection.rb +1 -0
- data/lib/graphql/pagination/relation_connection.rb +123 -22
- data/lib/graphql/pagination/sequel_dataset_connection.rb +1 -0
- data/lib/graphql/pagination.rb +1 -0
- data/lib/graphql/parse_error.rb +1 -0
- data/lib/graphql/query/context/scoped_context.rb +2 -1
- data/lib/graphql/query/context.rb +106 -35
- data/lib/graphql/query/fingerprint.rb +15 -7
- data/lib/graphql/query/input_validation_result.rb +1 -0
- data/lib/graphql/query/null_context.rb +1 -0
- data/lib/graphql/query/partial.rb +28 -15
- data/lib/graphql/query/result.rb +15 -5
- data/lib/graphql/query/validation_pipeline.rb +16 -6
- data/lib/graphql/query/variable_validation_error.rb +1 -0
- data/lib/graphql/query/variables.rb +9 -2
- data/lib/graphql/query.rb +193 -49
- data/lib/graphql/railtie.rb +7 -3
- data/lib/graphql/rake_task/validate.rb +72 -17
- data/lib/graphql/rake_task.rb +55 -23
- data/lib/graphql/relay/range_add.rb +32 -21
- data/lib/graphql/relay.rb +1 -0
- data/lib/graphql/rubocop/graphql/base_cop.rb +1 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +9 -6
- data/lib/graphql/rubocop/graphql/default_required_true.rb +9 -6
- data/lib/graphql/rubocop/graphql/field_type_in_block.rb +12 -8
- data/lib/graphql/rubocop/graphql/root_types_in_block.rb +9 -5
- data/lib/graphql/rubocop.rb +1 -0
- data/lib/graphql/runtime_error.rb +1 -0
- data/lib/graphql/runtime_type_error.rb +1 -0
- data/lib/graphql/schema/addition.rb +18 -6
- data/lib/graphql/schema/always_visible.rb +1 -0
- data/lib/graphql/schema/argument.rb +265 -42
- data/lib/graphql/schema/base_64_encoder.rb +2 -2
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -0
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +2 -2
- data/lib/graphql/schema/build_from_definition.rb +94 -27
- data/lib/graphql/schema/built_in_types.rb +1 -0
- data/lib/graphql/schema/directive/deprecated.rb +1 -0
- data/lib/graphql/schema/directive/feature.rb +39 -22
- data/lib/graphql/schema/directive/flagged.rb +6 -1
- data/lib/graphql/schema/directive/include.rb +1 -0
- data/lib/graphql/schema/directive/one_of.rb +1 -0
- data/lib/graphql/schema/directive/skip.rb +1 -0
- data/lib/graphql/schema/directive/specified_by.rb +1 -0
- data/lib/graphql/schema/directive/transform.rb +17 -8
- data/lib/graphql/schema/directive.rb +12 -7
- data/lib/graphql/schema/enum.rb +99 -38
- data/lib/graphql/schema/enum_value.rb +21 -13
- data/lib/graphql/schema/field/connection_extension.rb +10 -2
- data/lib/graphql/schema/field/scope_extension.rb +1 -0
- data/lib/graphql/schema/field.rb +621 -109
- data/lib/graphql/schema/field_extension.rb +89 -34
- data/lib/graphql/schema/find_inherited_value.rb +5 -3
- data/lib/graphql/schema/finder.rb +22 -8
- data/lib/graphql/schema/has_single_input_argument.rb +39 -6
- data/lib/graphql/schema/input_object.rb +40 -13
- data/lib/graphql/schema/interface.rb +33 -17
- data/lib/graphql/schema/introspection_system.rb +7 -3
- data/lib/graphql/schema/late_bound_type.rb +2 -2
- data/lib/graphql/schema/list.rb +15 -4
- data/lib/graphql/schema/loader.rb +23 -12
- data/lib/graphql/schema/member/base_dsl_methods.rb +58 -12
- data/lib/graphql/schema/member/build_type.rb +16 -5
- data/lib/graphql/schema/member/graphql_type_names.rb +10 -6
- data/lib/graphql/schema/member/has_arguments.rb +115 -48
- data/lib/graphql/schema/member/has_ast_node.rb +1 -0
- data/lib/graphql/schema/member/has_authorization.rb +5 -0
- data/lib/graphql/schema/member/has_dataloader.rb +91 -34
- data/lib/graphql/schema/member/has_deprecation_reason.rb +15 -2
- data/lib/graphql/schema/member/has_directives.rb +38 -10
- data/lib/graphql/schema/member/has_fields.rb +151 -70
- data/lib/graphql/schema/member/has_interfaces.rb +10 -2
- data/lib/graphql/schema/member/has_path.rb +14 -5
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +1 -0
- data/lib/graphql/schema/member/has_validators.rb +19 -4
- data/lib/graphql/schema/member/relay_shortcuts.rb +10 -2
- data/lib/graphql/schema/member/scoped.rb +14 -3
- data/lib/graphql/schema/member/type_system_helpers.rb +36 -6
- data/lib/graphql/schema/member/validates_input.rb +1 -0
- data/lib/graphql/schema/member.rb +9 -2
- data/lib/graphql/schema/mutation.rb +50 -46
- data/lib/graphql/schema/non_null.rb +21 -5
- data/lib/graphql/schema/object.rb +33 -12
- data/lib/graphql/schema/printer.rb +52 -31
- data/lib/graphql/schema/ractor_shareable.rb +6 -2
- data/lib/graphql/schema/relay_classic_mutation.rb +3 -3
- data/lib/graphql/schema/resolver/has_payload_type.rb +29 -7
- data/lib/graphql/schema/resolver.rb +156 -45
- data/lib/graphql/schema/scalar.rb +1 -0
- data/lib/graphql/schema/subscription.rb +67 -28
- data/lib/graphql/schema/timeout.rb +65 -25
- data/lib/graphql/schema/type_expression.rb +14 -5
- data/lib/graphql/schema/type_membership.rb +29 -10
- data/lib/graphql/schema/union.rb +4 -2
- data/lib/graphql/schema/unique_within_type.rb +24 -5
- data/lib/graphql/schema/validator/all_validator.rb +17 -9
- data/lib/graphql/schema/validator/allow_blank_validator.rb +8 -2
- data/lib/graphql/schema/validator/allow_null_validator.rb +8 -2
- data/lib/graphql/schema/validator/exclusion_validator.rb +14 -5
- data/lib/graphql/schema/validator/format_validator.rb +21 -10
- data/lib/graphql/schema/validator/inclusion_validator.rb +15 -6
- data/lib/graphql/schema/validator/length_validator.rb +23 -12
- data/lib/graphql/schema/validator/numericality_validator.rb +29 -16
- data/lib/graphql/schema/validator/required_validator.rb +45 -31
- data/lib/graphql/schema/validator.rb +89 -25
- data/lib/graphql/schema/visibility/migration.rb +14 -7
- data/lib/graphql/schema/visibility/profile.rb +65 -20
- data/lib/graphql/schema/visibility/visit.rb +12 -10
- data/lib/graphql/schema/visibility.rb +24 -20
- data/lib/graphql/schema/warden.rb +117 -31
- data/lib/graphql/schema/wrapper.rb +4 -1
- data/lib/graphql/schema.rb +1046 -300
- data/lib/graphql/static_validation/all_rules.rb +2 -1
- data/lib/graphql/static_validation/base_visitor.rb +59 -9
- data/lib/graphql/static_validation/definition_dependencies.rb +27 -7
- data/lib/graphql/static_validation/error.rb +3 -0
- data/lib/graphql/static_validation/interpreter_visitor.rb +1 -0
- data/lib/graphql/static_validation/literal_validator.rb +1 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +4 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +1 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +3 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +1 -0
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +3 -0
- data/lib/graphql/static_validation/rules/directives_are_defined_error.rb +1 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +3 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +3 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +9 -1
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +295 -134
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +14 -2
- data/lib/graphql/static_validation/rules/fragment_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_named.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_used.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_used_error.rb +1 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +3 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +3 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/not_single_subscription_error.rb +1 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +4 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +1 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid.rb +3 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid_error.rb +1 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +3 -0
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +4 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/subscription_root_exists_and_single_subscription_selection.rb +43 -5
- data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +3 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +3 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +207 -51
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +3 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +6 -3
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb +1 -0
- data/lib/graphql/static_validation/validation_context.rb +3 -2
- data/lib/graphql/static_validation/validation_timeout_error.rb +1 -0
- data/lib/graphql/static_validation/validator.rb +41 -16
- data/lib/graphql/static_validation.rb +1 -0
- data/lib/graphql/string_encoding_error.rb +1 -0
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +85 -65
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +10 -4
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +1 -0
- data/lib/graphql/subscriptions/event.rb +25 -6
- data/lib/graphql/subscriptions/serialize.rb +58 -19
- data/lib/graphql/subscriptions.rb +172 -46
- data/lib/graphql/testing/helpers.rb +17 -4
- data/lib/graphql/testing/mock_action_cable.rb +55 -33
- data/lib/graphql/testing.rb +1 -0
- data/lib/graphql/tracing/active_support_notifications_trace.rb +17 -9
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +2 -1
- data/lib/graphql/tracing/appoptics_trace.rb +2 -1
- data/lib/graphql/tracing/appoptics_tracing.rb +2 -1
- data/lib/graphql/tracing/appsignal_trace.rb +16 -7
- data/lib/graphql/tracing/appsignal_tracing.rb +7 -3
- data/lib/graphql/tracing/call_legacy_tracers.rb +1 -0
- data/lib/graphql/tracing/data_dog_trace.rb +17 -6
- data/lib/graphql/tracing/data_dog_tracing.rb +10 -3
- data/lib/graphql/tracing/detailed_trace/active_record_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace/memory_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace/redis_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace.rb +105 -42
- data/lib/graphql/tracing/legacy_hooks_trace.rb +5 -0
- data/lib/graphql/tracing/legacy_trace.rb +1 -0
- data/lib/graphql/tracing/monitor_trace.rb +17 -11
- data/lib/graphql/tracing/new_relic_trace.rb +17 -8
- data/lib/graphql/tracing/new_relic_tracing.rb +7 -3
- data/lib/graphql/tracing/notifications_trace.rb +11 -8
- data/lib/graphql/tracing/notifications_tracing.rb +23 -7
- data/lib/graphql/tracing/null_trace.rb +1 -0
- data/lib/graphql/tracing/perfetto_trace/trace_pb.rb +1 -0
- data/lib/graphql/tracing/perfetto_trace.rb +41 -19
- data/lib/graphql/tracing/platform_trace.rb +3 -1
- data/lib/graphql/tracing/platform_tracing.rb +16 -7
- data/lib/graphql/tracing/prometheus_trace/graphql_collector.rb +1 -0
- data/lib/graphql/tracing/prometheus_trace.rb +22 -13
- data/lib/graphql/tracing/prometheus_tracing.rb +1 -0
- data/lib/graphql/tracing/scout_trace.rb +10 -4
- data/lib/graphql/tracing/scout_tracing.rb +7 -3
- data/lib/graphql/tracing/sentry_trace.rb +12 -5
- data/lib/graphql/tracing/statsd_trace.rb +12 -6
- data/lib/graphql/tracing/statsd_tracing.rb +7 -1
- data/lib/graphql/tracing/trace.rb +231 -58
- data/lib/graphql/tracing.rb +25 -9
- data/lib/graphql/type_kinds.rb +2 -1
- data/lib/graphql/types/big_int.rb +1 -0
- data/lib/graphql/types/boolean.rb +1 -0
- data/lib/graphql/types/float.rb +1 -0
- data/lib/graphql/types/id.rb +1 -0
- data/lib/graphql/types/int.rb +2 -1
- data/lib/graphql/types/iso_8601_date.rb +21 -4
- data/lib/graphql/types/iso_8601_date_time.rb +33 -6
- data/lib/graphql/types/iso_8601_duration.rb +42 -9
- data/lib/graphql/types/json.rb +1 -0
- data/lib/graphql/types/relay/base_connection.rb +38 -32
- data/lib/graphql/types/relay/base_edge.rb +15 -9
- data/lib/graphql/types/relay/connection_behaviors.rb +19 -3
- data/lib/graphql/types/relay/edge_behaviors.rb +17 -4
- data/lib/graphql/types/relay/has_node_field.rb +6 -1
- data/lib/graphql/types/relay/has_nodes_field.rb +6 -1
- data/lib/graphql/types/relay/node.rb +1 -0
- data/lib/graphql/types/relay/node_behaviors.rb +5 -1
- data/lib/graphql/types/relay/page_info.rb +1 -0
- data/lib/graphql/types/relay/page_info_behaviors.rb +1 -0
- data/lib/graphql/types/relay.rb +4 -3
- data/lib/graphql/types/string.rb +1 -0
- data/lib/graphql/types.rb +1 -0
- data/lib/graphql/unauthorized_enum_value_error.rb +4 -1
- data/lib/graphql/unauthorized_error.rb +11 -4
- data/lib/graphql/unauthorized_field_error.rb +4 -1
- data/lib/graphql/unresolved_type_error.rb +16 -5
- data/lib/graphql/version.rb +2 -1
- data/lib/graphql.rb +37 -9
- data/readme.md +1 -1
- metadata +89 -5
- data/.yardopts +0 -5
data/lib/graphql/types/float.rb
CHANGED
data/lib/graphql/types/id.rb
CHANGED
data/lib/graphql/types/int.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Types
|
|
5
|
-
#
|
|
6
|
+
# See [Types::BigInt](rdoc-ref:Types::BigInt) for handling integers outside 32-bit range.
|
|
6
7
|
class Int < GraphQL::Schema::Scalar
|
|
7
8
|
description "Represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1."
|
|
8
9
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
module Types
|
|
4
5
|
# This scalar takes `Date`s and transmits them as strings,
|
|
@@ -16,14 +17,30 @@ module GraphQL
|
|
|
16
17
|
description "An ISO 8601-encoded date"
|
|
17
18
|
specified_by_url "https://tools.ietf.org/html/rfc3339"
|
|
18
19
|
|
|
19
|
-
#
|
|
20
|
-
#
|
|
20
|
+
# **Parameters**
|
|
21
|
+
#
|
|
22
|
+
# - `value` (`Date, Time, DateTime, String`)
|
|
23
|
+
#
|
|
24
|
+
# **Returns**
|
|
25
|
+
#
|
|
26
|
+
# - `String`
|
|
27
|
+
#
|
|
28
|
+
# :call-seq:
|
|
29
|
+
# coerce_result(Date | Time | DateTime | String value, _ctx) -> String
|
|
21
30
|
def self.coerce_result(value, _ctx)
|
|
22
31
|
Date.parse(value.to_s).iso8601
|
|
23
32
|
end
|
|
24
33
|
|
|
25
|
-
#
|
|
26
|
-
#
|
|
34
|
+
# **Parameters**
|
|
35
|
+
#
|
|
36
|
+
# - `str_value` (`String, Date, DateTime, Time`)
|
|
37
|
+
#
|
|
38
|
+
# **Returns**
|
|
39
|
+
#
|
|
40
|
+
# - `Date, nil`
|
|
41
|
+
#
|
|
42
|
+
# :call-seq:
|
|
43
|
+
# coerce_input(value, ctx) -> Date | nil
|
|
27
44
|
def self.coerce_input(value, ctx)
|
|
28
45
|
if value.is_a?(::Date)
|
|
29
46
|
value
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
require 'time'
|
|
4
5
|
|
|
@@ -23,18 +24,36 @@ module GraphQL
|
|
|
23
24
|
# i.e. ActiveSupport::JSON::Encoder.time_precision (3 by default)
|
|
24
25
|
DEFAULT_TIME_PRECISION = 0
|
|
25
26
|
|
|
26
|
-
#
|
|
27
|
+
# **Returns**
|
|
28
|
+
#
|
|
29
|
+
# - `Integer`
|
|
30
|
+
#
|
|
31
|
+
# :call-seq:
|
|
32
|
+
# time_precision() -> Integer
|
|
27
33
|
def self.time_precision
|
|
28
34
|
@time_precision || DEFAULT_TIME_PRECISION
|
|
29
35
|
end
|
|
30
36
|
|
|
31
|
-
#
|
|
37
|
+
# **Parameters**
|
|
38
|
+
#
|
|
39
|
+
# - `value` (`Integer`)
|
|
40
|
+
#
|
|
41
|
+
# :call-seq:
|
|
42
|
+
# time_precision=(Integer value)
|
|
32
43
|
def self.time_precision=(value)
|
|
33
44
|
@time_precision = value
|
|
34
45
|
end
|
|
35
46
|
|
|
36
|
-
#
|
|
37
|
-
#
|
|
47
|
+
# **Parameters**
|
|
48
|
+
#
|
|
49
|
+
# - `value` (`Time, Date, DateTime, String`)
|
|
50
|
+
#
|
|
51
|
+
# **Returns**
|
|
52
|
+
#
|
|
53
|
+
# - `String`
|
|
54
|
+
#
|
|
55
|
+
# :call-seq:
|
|
56
|
+
# coerce_result(Time | Date | DateTime | String value, _ctx) -> String
|
|
38
57
|
def self.coerce_result(value, _ctx)
|
|
39
58
|
case value
|
|
40
59
|
when Date
|
|
@@ -49,8 +68,16 @@ module GraphQL
|
|
|
49
68
|
raise GraphQL::Error, "An incompatible object (#{value.class}) was given to #{self}. Make sure that only Times, Dates, DateTimes, and well-formatted Strings are used with this type. (#{error.message})"
|
|
50
69
|
end
|
|
51
70
|
|
|
52
|
-
#
|
|
53
|
-
#
|
|
71
|
+
# **Parameters**
|
|
72
|
+
#
|
|
73
|
+
# - `str_value` (`String`)
|
|
74
|
+
#
|
|
75
|
+
# **Returns**
|
|
76
|
+
#
|
|
77
|
+
# - `Time`
|
|
78
|
+
#
|
|
79
|
+
# :call-seq:
|
|
80
|
+
# coerce_input(String str_value, _ctx) -> Time
|
|
54
81
|
def self.coerce_input(str_value, _ctx)
|
|
55
82
|
Time.iso8601(str_value)
|
|
56
83
|
rescue ArgumentError, TypeError
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
module Types
|
|
4
5
|
# This scalar takes `Duration`s and transmits them as strings,
|
|
@@ -16,20 +17,41 @@ module GraphQL
|
|
|
16
17
|
class ISO8601Duration < GraphQL::Schema::Scalar
|
|
17
18
|
description "An ISO 8601-encoded duration"
|
|
18
19
|
|
|
19
|
-
#
|
|
20
|
+
# **Returns**
|
|
21
|
+
#
|
|
22
|
+
# - `Integer, nil`
|
|
23
|
+
#
|
|
24
|
+
# :call-seq:
|
|
25
|
+
# seconds_precision() -> Integer | nil
|
|
20
26
|
def self.seconds_precision
|
|
21
27
|
# ActiveSupport::Duration precision defaults to whatever input was given
|
|
22
28
|
@seconds_precision
|
|
23
29
|
end
|
|
24
30
|
|
|
25
|
-
#
|
|
31
|
+
# **Parameters**
|
|
32
|
+
#
|
|
33
|
+
# - `value` (`Integer, nil`)
|
|
34
|
+
#
|
|
35
|
+
# :call-seq:
|
|
36
|
+
# seconds_precision=(Integer | nil value)
|
|
26
37
|
def self.seconds_precision=(value)
|
|
27
38
|
@seconds_precision = value
|
|
28
39
|
end
|
|
29
40
|
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
41
|
+
# **Parameters**
|
|
42
|
+
#
|
|
43
|
+
# - `value` (`ActiveSupport::Duration, String`)
|
|
44
|
+
#
|
|
45
|
+
# **Returns**
|
|
46
|
+
#
|
|
47
|
+
# - `String`
|
|
48
|
+
#
|
|
49
|
+
# **Raises**
|
|
50
|
+
#
|
|
51
|
+
# - `GraphQL::Error` — if ActiveSupport::Duration is not defined or if an incompatible object is passed
|
|
52
|
+
#
|
|
53
|
+
# :call-seq:
|
|
54
|
+
# coerce_result(ActiveSupport::Duration | String value, _ctx) -> String | GraphQL::Error
|
|
33
55
|
def self.coerce_result(value, _ctx)
|
|
34
56
|
unless defined?(ActiveSupport::Duration)
|
|
35
57
|
raise GraphQL::Error, "ActiveSupport >= 5.0 must be loaded to use the built-in ISO8601Duration type."
|
|
@@ -50,10 +72,21 @@ module GraphQL
|
|
|
50
72
|
end
|
|
51
73
|
end
|
|
52
74
|
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
75
|
+
# **Parameters**
|
|
76
|
+
#
|
|
77
|
+
# - `value` (`String, ActiveSupport::Duration`)
|
|
78
|
+
#
|
|
79
|
+
# **Returns**
|
|
80
|
+
#
|
|
81
|
+
# - `ActiveSupport::Duration, nil`
|
|
82
|
+
#
|
|
83
|
+
# **Raises**
|
|
84
|
+
#
|
|
85
|
+
# - `GraphQL::Error` — if ActiveSupport::Duration is not defined
|
|
86
|
+
# - `GraphQL::DurationEncodingError` — if duration cannot be parsed
|
|
87
|
+
#
|
|
88
|
+
# :call-seq:
|
|
89
|
+
# coerce_input(String | ActiveSupport::Duration value, ctx) -> ActiveSupport::Duration | nil | GraphQL::Error | GraphQL::DurationEncodingError
|
|
57
90
|
def self.coerce_input(value, ctx)
|
|
58
91
|
unless defined?(ActiveSupport::Duration)
|
|
59
92
|
raise GraphQL::Error, "ActiveSupport >= 5.0 must be loaded to use the built-in ISO8601Duration type."
|
data/lib/graphql/types/json.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Types
|
|
@@ -9,38 +10,43 @@ module GraphQL
|
|
|
9
10
|
# You may wish to copy this code into your own base class,
|
|
10
11
|
# so you can extend your own `BaseObject` instead of `GraphQL::Schema::Object`.
|
|
11
12
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
#
|
|
13
|
+
# See [Relay::BaseEdge](rdoc-ref:Relay::BaseEdge) for edge types
|
|
14
|
+
#
|
|
15
|
+
# **Examples**
|
|
16
|
+
#
|
|
17
|
+
# **Example: Implementation a connection and edge**
|
|
18
|
+
#
|
|
19
|
+
# ```ruby
|
|
20
|
+
# class BaseObject < GraphQL::Schema::Object; end
|
|
21
|
+
#
|
|
22
|
+
# # Given some object in your app ...
|
|
23
|
+
# class Types::Post < BaseObject
|
|
24
|
+
# end
|
|
25
|
+
#
|
|
26
|
+
# # Make a couple of base classes:
|
|
27
|
+
# class Types::BaseEdge < GraphQL::Types::Relay::BaseEdge; end
|
|
28
|
+
# class Types::BaseConnection < GraphQL::Types::Relay::BaseConnection; end
|
|
29
|
+
#
|
|
30
|
+
# # Then extend them for the object in your app
|
|
31
|
+
# class Types::PostEdge < Types::BaseEdge
|
|
32
|
+
# node_type Types::Post
|
|
33
|
+
# end
|
|
34
|
+
#
|
|
35
|
+
# class Types::PostConnection < Types::BaseConnection
|
|
36
|
+
# edge_type Types::PostEdge,
|
|
37
|
+
# edges_nullable: true,
|
|
38
|
+
# edge_nullable: true,
|
|
39
|
+
# node_nullable: true,
|
|
40
|
+
# nodes_field: true
|
|
41
|
+
#
|
|
42
|
+
# # Alternatively, you can call the class methods followed by your edge type
|
|
43
|
+
# # edges_nullable true
|
|
44
|
+
# # edge_nullable true
|
|
45
|
+
# # node_nullable true
|
|
46
|
+
# # has_nodes_field true
|
|
47
|
+
# # edge_type Types::PostEdge
|
|
48
|
+
# end
|
|
49
|
+
# ```
|
|
44
50
|
class BaseConnection < Schema::Object
|
|
45
51
|
include ConnectionBehaviors
|
|
46
52
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
module Types
|
|
4
5
|
module Relay
|
|
@@ -10,17 +11,22 @@ module GraphQL
|
|
|
10
11
|
# For example, you may want to extend your own `BaseObject` instead of the
|
|
11
12
|
# built-in `GraphQL::Schema::Object`.
|
|
12
13
|
#
|
|
13
|
-
#
|
|
14
|
-
# # Make a base class for your app
|
|
15
|
-
# class Types::BaseEdge < GraphQL::Types::Relay::BaseEdge
|
|
16
|
-
# end
|
|
14
|
+
# See [GraphQL::Types::Relay::BaseConnection](rdoc-ref:GraphQL::Types::Relay::BaseConnection) for connection types
|
|
17
15
|
#
|
|
18
|
-
#
|
|
19
|
-
# class Types::UserEdge < Types::BaseEdge
|
|
20
|
-
# node_type(Types::User)
|
|
21
|
-
# end
|
|
16
|
+
# **Examples**
|
|
22
17
|
#
|
|
23
|
-
#
|
|
18
|
+
# **Example: Making a UserEdge type**
|
|
19
|
+
#
|
|
20
|
+
# ```ruby
|
|
21
|
+
# # Make a base class for your app
|
|
22
|
+
# class Types::BaseEdge < GraphQL::Types::Relay::BaseEdge
|
|
23
|
+
# end
|
|
24
|
+
#
|
|
25
|
+
# # Then extend your own base class
|
|
26
|
+
# class Types::UserEdge < Types::BaseEdge
|
|
27
|
+
# node_type(Types::User)
|
|
28
|
+
# end
|
|
29
|
+
# ```
|
|
24
30
|
class BaseEdge < GraphQL::Schema::Object
|
|
25
31
|
include Types::Relay::EdgeBehaviors
|
|
26
32
|
end
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Types
|
|
5
6
|
module Relay
|
|
7
|
+
#--
|
|
8
|
+
# @requires_ancestor: GraphQL::Schema::Object
|
|
6
9
|
module ConnectionBehaviors
|
|
7
10
|
extend Forwardable
|
|
8
11
|
def_delegators :@object, :cursor_from_node, :parent
|
|
@@ -14,6 +17,7 @@ module GraphQL
|
|
|
14
17
|
child_class.edges_nullable(true)
|
|
15
18
|
child_class.edge_nullable(true)
|
|
16
19
|
child_class.module_exec {
|
|
20
|
+
#: self as GraphQL::Types::Relay::ConnectionBehaviors::ClassMethods
|
|
17
21
|
self.edge_type = nil
|
|
18
22
|
self.node_type = nil
|
|
19
23
|
self.edge_class = nil
|
|
@@ -22,6 +26,8 @@ module GraphQL
|
|
|
22
26
|
add_page_info_field(child_class)
|
|
23
27
|
end
|
|
24
28
|
|
|
29
|
+
#--
|
|
30
|
+
# @requires_ancestor: singleton(GraphQL::Schema::Object)
|
|
25
31
|
module ClassMethods
|
|
26
32
|
def inherited(child_class)
|
|
27
33
|
super
|
|
@@ -47,10 +53,14 @@ module GraphQL
|
|
|
47
53
|
@default_broadcastable = new_value
|
|
48
54
|
end
|
|
49
55
|
|
|
50
|
-
#
|
|
56
|
+
# **Returns**
|
|
57
|
+
#
|
|
58
|
+
# - `Class`
|
|
51
59
|
attr_reader :node_type
|
|
52
60
|
|
|
53
|
-
#
|
|
61
|
+
# **Returns**
|
|
62
|
+
#
|
|
63
|
+
# - `Class`
|
|
54
64
|
attr_reader :edge_class
|
|
55
65
|
|
|
56
66
|
# Configure this connection to return `edges` and `nodes` based on `edge_type_class`.
|
|
@@ -63,7 +73,13 @@ module GraphQL
|
|
|
63
73
|
# It's called when you subclass this base connection, trying to use the
|
|
64
74
|
# class name to set defaults. You can call it again in the class definition
|
|
65
75
|
# to override the default (or provide a value, if the default lookup failed).
|
|
66
|
-
#
|
|
76
|
+
#
|
|
77
|
+
# **Parameters**
|
|
78
|
+
#
|
|
79
|
+
# - `field_options` (`Hash`) — Any extra keyword arguments to pass to the `field :edges, ...` and `field :nodes, ...` configurations
|
|
80
|
+
#
|
|
81
|
+
# :call-seq:
|
|
82
|
+
# edge_type(edge_type_class, edge_class:, node_type:, nodes_field:, node_nullable:, edges_nullable:, edge_nullable:, Hash field_options:)
|
|
67
83
|
def edge_type(edge_type_class, edge_class: GraphQL::Pagination::Connection::Edge, node_type: edge_type_class.node_type, nodes_field: self.has_nodes_field, node_nullable: self.node_nullable, edges_nullable: self.edges_nullable, edge_nullable: self.edge_nullable, field_options: nil)
|
|
68
84
|
# Set this connection's graphql name
|
|
69
85
|
node_type_name = node_type.graphql_name
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Types
|
|
5
6
|
module Relay
|
|
7
|
+
#--
|
|
8
|
+
# @requires_ancestor: GraphQL::Schema::Object
|
|
6
9
|
module EdgeBehaviors
|
|
7
10
|
def self.included(child_class)
|
|
8
11
|
child_class.description("An edge in a connection.")
|
|
9
12
|
child_class.field(:cursor, String, null: false, description: "A cursor for use in pagination.")
|
|
10
13
|
child_class.extend(ClassMethods)
|
|
11
|
-
child_class.class_exec {
|
|
14
|
+
child_class.class_exec {
|
|
15
|
+
#: self as GraphQL::Types::Relay::EdgeBehaviors::ClassMethods
|
|
16
|
+
self.node_type = nil
|
|
17
|
+
}
|
|
12
18
|
child_class.node_nullable(true)
|
|
13
19
|
child_class.default_broadcastable(nil)
|
|
14
20
|
end
|
|
@@ -21,6 +27,8 @@ module GraphQL
|
|
|
21
27
|
@object.node
|
|
22
28
|
end
|
|
23
29
|
|
|
30
|
+
#--
|
|
31
|
+
# @requires_ancestor: singleton(GraphQL::Schema::Object)
|
|
24
32
|
module ClassMethods
|
|
25
33
|
def inherited(child_class)
|
|
26
34
|
super
|
|
@@ -43,9 +51,14 @@ module GraphQL
|
|
|
43
51
|
|
|
44
52
|
# Get or set the Object type that this edge wraps.
|
|
45
53
|
#
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
54
|
+
# **Parameters**
|
|
55
|
+
#
|
|
56
|
+
# - `node_type` (`Class`) — A `Schema::Object` subclass
|
|
57
|
+
# - `null` (`Boolean`)
|
|
58
|
+
# - `field_options` (`Hash`) — Any extra arguments to pass to the `field :node` configuration
|
|
59
|
+
#
|
|
60
|
+
# :call-seq:
|
|
61
|
+
# node_type(Class node_type, bool null:, Hash field_options:)
|
|
49
62
|
def node_type(node_type = nil, null: self.node_nullable, field_options: nil)
|
|
50
63
|
if node_type
|
|
51
64
|
@node_type = node_type
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Types
|
|
5
6
|
module Relay
|
|
6
7
|
# Include this module to your root Query type to get a Relay-compliant `node(id: ID!): Node` field that uses the schema's `object_from_id` hook.
|
|
8
|
+
#--
|
|
9
|
+
# @requires_ancestor: GraphQL::Schema::Object
|
|
7
10
|
module HasNodeField
|
|
8
11
|
def self.included(child_class)
|
|
9
12
|
child_class.field(**field_options, &field_block)
|
|
@@ -17,7 +20,8 @@ module GraphQL
|
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
def get_relay_node(id:)
|
|
20
|
-
self.class
|
|
23
|
+
query_class = self.class #: as GraphQL::Types::Relay::HasNodeField::ExecutionMethods
|
|
24
|
+
query_class.get_relay_node(context, id: id)
|
|
21
25
|
end
|
|
22
26
|
|
|
23
27
|
class << self
|
|
@@ -35,6 +39,7 @@ module GraphQL
|
|
|
35
39
|
|
|
36
40
|
def field_block
|
|
37
41
|
Proc.new {
|
|
42
|
+
#: self as GraphQL::Schema::Field
|
|
38
43
|
argument :id, "ID!",
|
|
39
44
|
description: "ID of the object."
|
|
40
45
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Types
|
|
5
6
|
module Relay
|
|
6
7
|
# Include this module to your root Query type to get a Relay-style `nodes(id: ID!): [Node]` field that uses the schema's `object_from_id` hook.
|
|
8
|
+
#--
|
|
9
|
+
# @requires_ancestor: GraphQL::Schema::Object
|
|
7
10
|
module HasNodesField
|
|
8
11
|
def self.included(child_class)
|
|
9
12
|
child_class.field(**field_options, &field_block)
|
|
@@ -17,7 +20,8 @@ module GraphQL
|
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
def get_relay_nodes(ids:)
|
|
20
|
-
self.class
|
|
23
|
+
query_class = self.class #: as GraphQL::Types::Relay::HasNodesField::ExecutionMethods
|
|
24
|
+
query_class.get_relay_nodes(context, ids: ids)
|
|
21
25
|
end
|
|
22
26
|
|
|
23
27
|
class << self
|
|
@@ -35,6 +39,7 @@ module GraphQL
|
|
|
35
39
|
|
|
36
40
|
def field_block
|
|
37
41
|
Proc.new {
|
|
42
|
+
#: self as GraphQL::Schema::Field
|
|
38
43
|
argument :ids, "[ID!]!",
|
|
39
44
|
description: "IDs of the objects."
|
|
40
45
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
module Types
|
|
5
6
|
module Relay
|
|
7
|
+
#--
|
|
8
|
+
# @requires_ancestor: GraphQL::Schema::Object
|
|
6
9
|
module NodeBehaviors
|
|
7
10
|
def self.included(child_module)
|
|
8
11
|
child_module.extend(ClassMethods)
|
|
@@ -12,7 +15,8 @@ module GraphQL
|
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
def default_global_id
|
|
15
|
-
self.class
|
|
18
|
+
node_class = self.class #: as GraphQL::Types::Relay::NodeBehaviors::ExecutionMethods
|
|
19
|
+
node_class.default_global_id(object, context)
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
module ClassMethods
|
data/lib/graphql/types/relay.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
# behavior modules:
|
|
4
5
|
require "graphql/types/relay/connection_behaviors"
|
|
@@ -23,11 +24,11 @@ module GraphQL
|
|
|
23
24
|
# open up the source files and copy the relevant methods and configuration into
|
|
24
25
|
# your own classes.
|
|
25
26
|
#
|
|
26
|
-
# For example, the provided object types extend
|
|
27
|
+
# For example, the provided object types extend `Types::Relay::BaseObject`,
|
|
27
28
|
# but you might want to:
|
|
28
29
|
#
|
|
29
|
-
# 1. Migrate the extensions from
|
|
30
|
-
# 2. Copy
|
|
30
|
+
# 1. Migrate the extensions from `Types::Relay::BaseObject` into _your app's_ base object
|
|
31
|
+
# 2. Copy [Relay::BaseConnection](rdoc-ref:Relay::BaseConnection), [Relay::BaseEdge](rdoc-ref:Relay::BaseEdge), etc into _your app_, and
|
|
31
32
|
# change them to extend _your_ base object.
|
|
32
33
|
#
|
|
33
34
|
# Similarly, `BaseField`'s extensions could be migrated to your app
|
data/lib/graphql/types/string.rb
CHANGED
data/lib/graphql/types.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class UnauthorizedEnumValueError < GraphQL::UnauthorizedError
|
|
4
|
-
#
|
|
5
|
+
# **Returns**
|
|
6
|
+
#
|
|
7
|
+
# - `GraphQL::Schema::EnumValue` — The value whose `#authorized?` check returned false
|
|
5
8
|
attr_accessor :enum_value
|
|
6
9
|
|
|
7
10
|
def initialize(type:, context:, enum_value:)
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
# When an `authorized?` hook returns false, this error is used to communicate the failure.
|
|
4
|
-
# It's passed to
|
|
5
|
+
# It's passed to [Schema.unauthorized_object](rdoc-ref:Schema.unauthorized_object).
|
|
5
6
|
#
|
|
6
7
|
# Alternatively, custom code in `authorized?` may raise this error. It will be routed the same way.
|
|
7
8
|
class UnauthorizedError < GraphQL::RuntimeError
|
|
8
|
-
#
|
|
9
|
+
# **Returns**
|
|
10
|
+
#
|
|
11
|
+
# - `Object` — the application object that failed the authorization check
|
|
9
12
|
attr_reader :object
|
|
10
13
|
|
|
11
|
-
#
|
|
14
|
+
# **Returns**
|
|
15
|
+
#
|
|
16
|
+
# - `Class` — the GraphQL object type whose `.authorized?` method was called (and returned false)
|
|
12
17
|
attr_reader :type
|
|
13
18
|
|
|
14
|
-
#
|
|
19
|
+
# **Returns**
|
|
20
|
+
#
|
|
21
|
+
# - `GraphQL::Query::Context` — the context for the current query
|
|
15
22
|
attr_accessor :context
|
|
16
23
|
|
|
17
24
|
def initialize(message = nil, object: nil, type: nil, context: nil)
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class UnauthorizedFieldError < GraphQL::UnauthorizedError
|
|
4
|
-
#
|
|
5
|
+
# **Returns**
|
|
6
|
+
#
|
|
7
|
+
# - `Field` — the field that failed the authorization check
|
|
5
8
|
attr_accessor :field
|
|
6
9
|
|
|
7
10
|
def initialize(message = nil, object: nil, type: nil, context: nil, field: nil)
|