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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 36d986ef7f7b1916194937668e714823fcc92844d9cbbd3adebad6fae134f9ff
|
|
4
|
+
data.tar.gz: 84b4da9a3b9fc6c56cf6b8a5629567609a91c50eae60ac8ac825218cd0f73d4c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2ecdf1096d357f3413087513d2076d2e6ed8d56c29cc9a535b24f2b8d16df88055abec49b2dbf423c315dbbfe0f58a30b0e9507c6a6d63152e77c949e53a3c70
|
|
7
|
+
data.tar.gz: e19b69ee6bcf4db6f58f53e990ba8aa9ca5a70e0b8dce3174ae2ca10f62226d7fc12a75a3d3f74f521094453ab37f724c225477173bd42c8ede70269809a701b
|
data/.rdoc_options
ADDED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: ignore
|
|
2
3
|
require 'rails/generators'
|
|
3
4
|
require "rails/generators/named_base"
|
|
4
5
|
require_relative "core"
|
|
5
6
|
|
|
6
7
|
module Graphql
|
|
7
8
|
module Generators
|
|
8
|
-
#
|
|
9
|
-
#
|
|
9
|
+
# **Examples**
|
|
10
|
+
#
|
|
11
|
+
# **Example: Generate a `GraphQL::Batch` loader by name.**
|
|
12
|
+
#
|
|
13
|
+
# ```ruby
|
|
14
|
+
# rails g graphql:loader RecordLoader
|
|
15
|
+
# ```
|
|
10
16
|
class LoaderGenerator < Rails::Generators::NamedBase
|
|
11
17
|
include Core
|
|
12
18
|
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: ignore
|
|
2
3
|
require_relative 'orm_mutations_base'
|
|
3
4
|
|
|
4
5
|
module Graphql
|
|
5
6
|
module Generators
|
|
6
7
|
# TODO: What other options should be supported?
|
|
7
8
|
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
9
|
+
# **Examples**
|
|
10
|
+
#
|
|
11
|
+
# **Example: Generate a `GraphQL::Schema::RelayClassicMutation` by name**
|
|
12
|
+
#
|
|
13
|
+
# ```ruby
|
|
14
|
+
# rails g graphql:mutation CreatePostMutation
|
|
15
|
+
# ```
|
|
10
16
|
class MutationCreateGenerator < OrmMutationsBase
|
|
11
17
|
|
|
12
18
|
desc "Scaffold a Relay Classic ORM create mutation for the given model class"
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: ignore
|
|
2
3
|
require_relative 'orm_mutations_base'
|
|
3
4
|
|
|
4
5
|
module Graphql
|
|
5
6
|
module Generators
|
|
6
7
|
# TODO: What other options should be supported?
|
|
7
8
|
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
9
|
+
# **Examples**
|
|
10
|
+
#
|
|
11
|
+
# **Example: Generate a `GraphQL::Schema::RelayClassicMutation` by name**
|
|
12
|
+
#
|
|
13
|
+
# ```ruby
|
|
14
|
+
# rails g graphql:mutation DeletePostMutation
|
|
15
|
+
# ```
|
|
10
16
|
class MutationDeleteGenerator < OrmMutationsBase
|
|
11
17
|
|
|
12
18
|
desc "Scaffold a Relay Classic ORM delete mutation for the given model class"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: ignore
|
|
2
3
|
require 'rails/generators'
|
|
3
4
|
require 'rails/generators/named_base'
|
|
4
5
|
require_relative 'core'
|
|
@@ -7,8 +8,13 @@ module Graphql
|
|
|
7
8
|
module Generators
|
|
8
9
|
# TODO: What other options should be supported?
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
11
|
+
# **Examples**
|
|
12
|
+
#
|
|
13
|
+
# **Example: Generate a `GraphQL::Schema::RelayClassicMutation` by name**
|
|
14
|
+
#
|
|
15
|
+
# ```ruby
|
|
16
|
+
# rails g graphql:mutation CreatePostMutation
|
|
17
|
+
# ```
|
|
12
18
|
class MutationGenerator < Rails::Generators::NamedBase
|
|
13
19
|
include Core
|
|
14
20
|
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: ignore
|
|
2
3
|
require_relative 'orm_mutations_base'
|
|
3
4
|
|
|
4
5
|
module Graphql
|
|
5
6
|
module Generators
|
|
6
7
|
# TODO: What other options should be supported?
|
|
7
8
|
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
9
|
+
# **Examples**
|
|
10
|
+
#
|
|
11
|
+
# **Example: Generate a `GraphQL::Schema::RelayClassicMutation` by name**
|
|
12
|
+
#
|
|
13
|
+
# ```ruby
|
|
14
|
+
# rails g graphql:mutation UpdatePostMutation
|
|
15
|
+
# ```
|
|
10
16
|
class MutationUpdateGenerator < OrmMutationsBase
|
|
11
17
|
|
|
12
18
|
desc "Scaffold a Relay Classic ORM update mutation for the given model class"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: ignore
|
|
2
3
|
require 'rails/generators'
|
|
3
4
|
require 'rails/generators/named_base'
|
|
4
5
|
require_relative 'core'
|
|
@@ -7,8 +8,13 @@ module Graphql
|
|
|
7
8
|
module Generators
|
|
8
9
|
# TODO: What other options should be supported?
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
11
|
+
# **Examples**
|
|
12
|
+
#
|
|
13
|
+
# **Example: Generate a `GraphQL::Schema::RelayClassicMutation` by name**
|
|
14
|
+
#
|
|
15
|
+
# ```ruby
|
|
16
|
+
# rails g graphql:mutation CreatePostMutation
|
|
17
|
+
# ```
|
|
12
18
|
class OrmMutationsBase < Rails::Generators::NamedBase
|
|
13
19
|
include Core
|
|
14
20
|
include Rails::Generators::ResourceHelpers
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: ignore
|
|
2
3
|
require 'rails/generators'
|
|
3
4
|
require 'rails/generators/base'
|
|
4
5
|
require 'graphql'
|
|
@@ -34,10 +35,19 @@ module Graphql
|
|
|
34
35
|
# Take a type expression in any combination of GraphQL or Ruby styles
|
|
35
36
|
# and return it in a specified output style
|
|
36
37
|
# TODO: nullability / list with `mode: :graphql` doesn't work
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
38
|
+
#
|
|
39
|
+
# **Parameters**
|
|
40
|
+
#
|
|
41
|
+
# - `type_expresson` (`String`)
|
|
42
|
+
# - `mode` (`Symbol`)
|
|
43
|
+
# - `null` (`Boolean`)
|
|
44
|
+
#
|
|
45
|
+
# **Returns**
|
|
46
|
+
#
|
|
47
|
+
# - `(String, Boolean)` — The type expression, followed by `null:` value
|
|
48
|
+
#
|
|
49
|
+
# :call-seq:
|
|
50
|
+
# normalize_type_expression(type_expression, Symbol mode:, bool null:) -> (String, bool)
|
|
41
51
|
def self.normalize_type_expression(type_expression, mode:, null: true)
|
|
42
52
|
if type_expression.start_with?("!")
|
|
43
53
|
normalize_type_expression(type_expression[1..-1], mode: mode, null: false)
|
|
@@ -73,22 +83,42 @@ module Graphql
|
|
|
73
83
|
|
|
74
84
|
private
|
|
75
85
|
|
|
76
|
-
#
|
|
86
|
+
# **Returns**
|
|
87
|
+
#
|
|
88
|
+
# - `String` — The user-provided type name, normalized to Ruby code
|
|
89
|
+
#
|
|
90
|
+
# :call-seq:
|
|
91
|
+
# type_ruby_name() -> String
|
|
77
92
|
def type_ruby_name
|
|
78
93
|
@type_ruby_name ||= self.class.normalize_type_expression(name, mode: :ruby)[0]
|
|
79
94
|
end
|
|
80
95
|
|
|
81
|
-
#
|
|
96
|
+
# **Returns**
|
|
97
|
+
#
|
|
98
|
+
# - `String` — The user-provided type name, as a GraphQL name
|
|
99
|
+
#
|
|
100
|
+
# :call-seq:
|
|
101
|
+
# type_graphql_name() -> String
|
|
82
102
|
def type_graphql_name
|
|
83
103
|
@type_graphql_name ||= self.class.normalize_type_expression(name, mode: :graphql)[0]
|
|
84
104
|
end
|
|
85
105
|
|
|
86
|
-
#
|
|
106
|
+
# **Returns**
|
|
107
|
+
#
|
|
108
|
+
# - `String` — The user-provided type name, as a file name (without extension)
|
|
109
|
+
#
|
|
110
|
+
# :call-seq:
|
|
111
|
+
# type_file_name() -> String
|
|
87
112
|
def type_file_name
|
|
88
113
|
@type_file_name ||= "#{type_graphql_name}Type".underscore
|
|
89
114
|
end
|
|
90
115
|
|
|
91
|
-
#
|
|
116
|
+
# **Returns**
|
|
117
|
+
#
|
|
118
|
+
# - `Array<NormalizedField>` — User-provided fields, in `(name, Ruby type name)` pairs
|
|
119
|
+
#
|
|
120
|
+
# :call-seq:
|
|
121
|
+
# normalized_fields() -> Array[NormalizedField]
|
|
92
122
|
def normalized_fields
|
|
93
123
|
@normalized_fields ||= fields.map { |f|
|
|
94
124
|
name, raw_type = f.split(":", 2)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
module Analysis
|
|
4
5
|
# Query analyzer for query ASTs. Query analyzers respond to visitor style methods
|
|
@@ -7,7 +8,9 @@ module GraphQL
|
|
|
7
8
|
# When an analyzer is initialized with a Multiplex, you can always get the current query from
|
|
8
9
|
# `visitor.query` in the visit methods.
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
+
# **Parameters**
|
|
12
|
+
#
|
|
13
|
+
# - `The` (`GraphQL::Query, GraphQL::Execution::Multiplex`) — query or multiplex to analyze
|
|
11
14
|
class Analyzer
|
|
12
15
|
def initialize(subject)
|
|
13
16
|
@subject = subject
|
|
@@ -23,21 +26,39 @@ module GraphQL
|
|
|
23
26
|
|
|
24
27
|
# Analyzer hook to decide at analysis time whether a query should
|
|
25
28
|
# be analyzed or not.
|
|
26
|
-
#
|
|
29
|
+
#
|
|
30
|
+
# **Returns**
|
|
31
|
+
#
|
|
32
|
+
# - `Boolean` — If the query should be analyzed or not
|
|
33
|
+
#
|
|
34
|
+
# :call-seq:
|
|
35
|
+
# analyze?() -> bool
|
|
27
36
|
def analyze?
|
|
28
37
|
true
|
|
29
38
|
end
|
|
30
39
|
|
|
31
40
|
# Analyzer hook to decide at analysis time whether analysis
|
|
32
41
|
# requires a visitor pass; can be disabled for precomputed results.
|
|
33
|
-
#
|
|
42
|
+
#
|
|
43
|
+
# **Returns**
|
|
44
|
+
#
|
|
45
|
+
# - `Boolean` — If analysis requires visitation or not
|
|
46
|
+
#
|
|
47
|
+
# :call-seq:
|
|
48
|
+
# visit?() -> bool
|
|
34
49
|
def visit?
|
|
35
50
|
true
|
|
36
51
|
end
|
|
37
52
|
|
|
38
|
-
# The result for this analyzer. Returning
|
|
53
|
+
# The result for this analyzer. Returning [GraphQL::AnalysisError](rdoc-ref:GraphQL::AnalysisError) results
|
|
39
54
|
# in a query error.
|
|
40
|
-
#
|
|
55
|
+
#
|
|
56
|
+
# **Returns**
|
|
57
|
+
#
|
|
58
|
+
# - `Any` — The analyzer result
|
|
59
|
+
#
|
|
60
|
+
# :call-seq:
|
|
61
|
+
# result() -> Any
|
|
41
62
|
def result
|
|
42
63
|
raise GraphQL::RequiredImplementationMissingError
|
|
43
64
|
end
|
|
@@ -76,14 +97,19 @@ module GraphQL
|
|
|
76
97
|
# rubocop:enable Development/NoEvalCop
|
|
77
98
|
protected
|
|
78
99
|
|
|
79
|
-
#
|
|
100
|
+
# **Returns**
|
|
101
|
+
#
|
|
102
|
+
# - `GraphQL::Query, GraphQL::Execution::Multiplex` — Whatever this analyzer is analyzing
|
|
80
103
|
attr_reader :subject
|
|
81
104
|
|
|
82
|
-
#
|
|
83
|
-
#
|
|
105
|
+
# **Returns**
|
|
106
|
+
#
|
|
107
|
+
# - `GraphQL::Query, nil` — `nil` if this analyzer is visiting a multiplex (When this is `nil`, use `visitor.query` inside visit methods to get the current query)
|
|
84
108
|
attr_reader :query
|
|
85
109
|
|
|
86
|
-
#
|
|
110
|
+
# **Returns**
|
|
111
|
+
#
|
|
112
|
+
# - `GraphQL::Execution::Multiplex, nil` — `nil` if this analyzer is visiting a query
|
|
87
113
|
attr_reader :multiplex
|
|
88
114
|
end
|
|
89
115
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
module Analysis
|
|
4
5
|
# Used under the hood to implement complexity validation,
|
|
5
|
-
#
|
|
6
|
+
# See [Schema.max_complexity](rdoc-ref:GraphQL::Schema.max_complexity) and `Query#max_complexity`.
|
|
6
7
|
class MaxQueryComplexity < QueryComplexity
|
|
7
8
|
def result
|
|
8
9
|
return if subject.max_complexity.nil?
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
module Analysis
|
|
4
|
-
# Calculate the complexity of a query, using
|
|
5
|
+
# Calculate the complexity of a query, using [Field#complexity](rdoc-ref:GraphQL::Schema::Field#complexity) values.
|
|
5
6
|
class QueryComplexity < Analyzer
|
|
6
7
|
# State for the query complexity calculation:
|
|
7
8
|
# - `complexities_on_type` holds complexity scores for each type
|
|
@@ -51,11 +52,19 @@ module GraphQL
|
|
|
51
52
|
|
|
52
53
|
attr_reader :field_definition, :response_path, :query
|
|
53
54
|
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
55
|
+
# **Parameters**
|
|
56
|
+
#
|
|
57
|
+
# - `parent_type` (`Class`) — The owner of `field_definition`
|
|
58
|
+
# - `field_definition` (`GraphQL::Field, GraphQL::Schema::Field`) — Used for getting the `.complexity` configuration
|
|
59
|
+
# - `query` (`GraphQL::Query`) — Used for `query.possible_types`
|
|
60
|
+
# - `response_path` (`Array<String>`) — The path to the response key for the field
|
|
61
|
+
#
|
|
62
|
+
# **Returns**
|
|
63
|
+
#
|
|
64
|
+
# - `Hash<GraphQL::BaseType, Hash<String, ScopedTypeComplexity>>`
|
|
65
|
+
#
|
|
66
|
+
# :call-seq:
|
|
67
|
+
# initialize(Class parent_type, GraphQL::Field | GraphQL::Schema::Field field_definition, GraphQL::Query query, Array[String] response_path) -> Hash[GraphQL::BaseType, Hash[String, ScopedTypeComplexity]]
|
|
59
68
|
def initialize(parent_type, field_definition, query, response_path)
|
|
60
69
|
super(&DEFAULT_PROC)
|
|
61
70
|
@parent_type = parent_type
|
|
@@ -65,7 +74,9 @@ module GraphQL
|
|
|
65
74
|
@nodes = []
|
|
66
75
|
end
|
|
67
76
|
|
|
68
|
-
#
|
|
77
|
+
# **Returns**
|
|
78
|
+
#
|
|
79
|
+
# - `Array<GraphQL::Language::Nodes::Field>`
|
|
69
80
|
attr_reader :nodes
|
|
70
81
|
|
|
71
82
|
def own_complexity(child_complexity)
|
|
@@ -107,17 +118,30 @@ module GraphQL
|
|
|
107
118
|
|
|
108
119
|
private
|
|
109
120
|
|
|
110
|
-
#
|
|
121
|
+
# **Returns**
|
|
122
|
+
#
|
|
123
|
+
# - `Integer`
|
|
124
|
+
#
|
|
125
|
+
# :call-seq:
|
|
126
|
+
# max_possible_complexity(mode:) -> Integer
|
|
111
127
|
def max_possible_complexity(mode: :future)
|
|
112
128
|
@complexities_on_type_by_query.reduce(0) do |total, (query, scopes_stack)|
|
|
113
129
|
total + merged_max_complexity_for_scopes(query, [scopes_stack.first], mode)
|
|
114
130
|
end
|
|
115
131
|
end
|
|
116
132
|
|
|
117
|
-
#
|
|
118
|
-
#
|
|
119
|
-
#
|
|
120
|
-
#
|
|
133
|
+
# **Parameters**
|
|
134
|
+
#
|
|
135
|
+
# - `query` (`GraphQL::Query`) — Used for `query.possible_types`
|
|
136
|
+
# - `scopes` (`Array<ScopedTypeComplexity>`) — Array of scoped type complexities
|
|
137
|
+
# - `mode` (`:future, :legacy`)
|
|
138
|
+
#
|
|
139
|
+
# **Returns**
|
|
140
|
+
#
|
|
141
|
+
# - `Integer`
|
|
142
|
+
#
|
|
143
|
+
# :call-seq:
|
|
144
|
+
# merged_max_complexity_for_scopes(GraphQL::Query query, Array[ScopedTypeComplexity] scopes, :future | :legacy mode) -> Integer
|
|
121
145
|
def merged_max_complexity_for_scopes(query, scopes, mode)
|
|
122
146
|
# Aggregate a set of all possible scope types encountered (scope keys).
|
|
123
147
|
# Use a hash, but ignore the values; it's just a fast way to work with the keys.
|
|
@@ -182,14 +206,27 @@ module GraphQL
|
|
|
182
206
|
# A hook which is called whenever a field's max complexity is calculated.
|
|
183
207
|
# Override this method to capture individual field complexity details.
|
|
184
208
|
#
|
|
185
|
-
#
|
|
186
|
-
#
|
|
187
|
-
#
|
|
209
|
+
# **Parameters**
|
|
210
|
+
#
|
|
211
|
+
# - `scoped_type_complexity` (`ScopedTypeComplexity`)
|
|
212
|
+
# - `max_complexity` (`Numeric`) — Field's maximum complexity including child complexity
|
|
213
|
+
# - `child_complexity` (`Numeric, nil`) — Field's child complexity
|
|
214
|
+
#
|
|
215
|
+
# :call-seq:
|
|
216
|
+
# field_complexity(ScopedTypeComplexity scoped_type_complexity, Numeric max_complexity:, Numeric | nil child_complexity:)
|
|
188
217
|
def field_complexity(scoped_type_complexity, max_complexity:, child_complexity: nil)
|
|
189
218
|
end
|
|
190
219
|
|
|
191
|
-
#
|
|
192
|
-
#
|
|
220
|
+
# **Parameters**
|
|
221
|
+
#
|
|
222
|
+
# - `inner_selections` (`Array<Hash<String, ScopedTypeComplexity>>`) — Field selections for a scope
|
|
223
|
+
#
|
|
224
|
+
# **Returns**
|
|
225
|
+
#
|
|
226
|
+
# - `Integer` — Total complexity value for all these selections in the parent scope
|
|
227
|
+
#
|
|
228
|
+
# :call-seq:
|
|
229
|
+
# merged_max_complexity(query, Array[Hash[String, ScopedTypeComplexity]] inner_selections) -> Integer
|
|
193
230
|
def merged_max_complexity(query, inner_selections)
|
|
194
231
|
child_scopes_by_key = {}
|
|
195
232
|
inner_selections.each do |inner_selection|
|
|
@@ -211,7 +248,7 @@ module GraphQL
|
|
|
211
248
|
end
|
|
212
249
|
|
|
213
250
|
# Identify the maximum cost and scope among possibilities
|
|
214
|
-
maximum_cost = 0
|
|
251
|
+
maximum_cost = 0 #: Integer
|
|
215
252
|
maximum_scope = child_scopes.reduce(child_scopes.last) do |max_scope, possible_scope|
|
|
216
253
|
scope_cost = possible_scope.own_complexity(maximum_children_cost)
|
|
217
254
|
if scope_cost > maximum_cost
|
|
@@ -243,8 +280,8 @@ module GraphQL
|
|
|
243
280
|
|
|
244
281
|
# Add up the total cost for each unique field name's coalesced selections
|
|
245
282
|
unique_field_keys.each_key.reduce(0) do |total, field_key|
|
|
246
|
-
composite_scopes = nil
|
|
247
|
-
field_cost = 0
|
|
283
|
+
composite_scopes = nil #: Array[untyped]?
|
|
284
|
+
field_cost = 0 #: Integer
|
|
248
285
|
|
|
249
286
|
# Collect composite selection scopes for further aggregation,
|
|
250
287
|
# leaf selections report their costs directly.
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
module Analysis
|
|
4
5
|
# A query reducer for measuring the depth of a given query.
|
|
5
6
|
#
|
|
6
7
|
# See https://graphql-ruby.org/queries/ast_analysis.html for more examples.
|
|
7
8
|
#
|
|
8
|
-
#
|
|
9
|
-
# class LogQueryDepth < GraphQL::Analysis::QueryDepth
|
|
10
|
-
# def result
|
|
11
|
-
# log("GraphQL query depth: #{@max_depth}")
|
|
12
|
-
# end
|
|
13
|
-
# end
|
|
9
|
+
# **Examples**
|
|
14
10
|
#
|
|
15
|
-
#
|
|
11
|
+
# **Example: Logging the depth of a query**
|
|
16
12
|
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
13
|
+
# ```ruby
|
|
14
|
+
# class LogQueryDepth < GraphQL::Analysis::QueryDepth
|
|
15
|
+
# def result
|
|
16
|
+
# log("GraphQL query depth: #{@max_depth}")
|
|
19
17
|
# end
|
|
18
|
+
# end
|
|
19
|
+
#
|
|
20
|
+
# # In your Schema file:
|
|
20
21
|
#
|
|
21
|
-
#
|
|
22
|
+
# class MySchema < GraphQL::Schema
|
|
23
|
+
# query_analyzer LogQueryDepth
|
|
24
|
+
# end
|
|
22
25
|
#
|
|
23
|
-
#
|
|
24
|
-
# # GraphQL query depth: 8
|
|
26
|
+
# # When you run the query, the depth will get logged:
|
|
25
27
|
#
|
|
28
|
+
# Schema.execute(query_str)
|
|
29
|
+
# # GraphQL query depth: 8
|
|
30
|
+
# ```
|
|
26
31
|
class QueryDepth < Analyzer
|
|
27
32
|
def initialize(query)
|
|
28
33
|
@max_depth = 0
|