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,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
module Analysis
|
|
4
5
|
# Depth first traversal through a query AST, calling AST analyzers
|
|
@@ -8,7 +9,7 @@ module GraphQL
|
|
|
8
9
|
# only the selected operation, providing helpers for common use cases such
|
|
9
10
|
# as skipped fields and visiting fragment spreads.
|
|
10
11
|
#
|
|
11
|
-
#
|
|
12
|
+
# See [GraphQL::Analysis::Analyzer](rdoc-ref:GraphQL::Analysis::Analyzer) AST Analyzers for queries
|
|
12
13
|
class Visitor < GraphQL::Language::StaticVisitor
|
|
13
14
|
def initialize(query:, analyzers:, timeout:)
|
|
14
15
|
@analyzers = analyzers
|
|
@@ -32,13 +33,19 @@ module GraphQL
|
|
|
32
33
|
super(query.selected_operation)
|
|
33
34
|
end
|
|
34
35
|
|
|
35
|
-
#
|
|
36
|
+
# **Returns**
|
|
37
|
+
#
|
|
38
|
+
# - `GraphQL::Query` — the query being visited
|
|
36
39
|
attr_reader :query
|
|
37
40
|
|
|
38
|
-
#
|
|
41
|
+
# **Returns**
|
|
42
|
+
#
|
|
43
|
+
# - `Array<GraphQL::ObjectType>` — Types whose scope we've entered
|
|
39
44
|
attr_reader :object_types
|
|
40
45
|
|
|
41
|
-
#
|
|
46
|
+
# **Returns**
|
|
47
|
+
#
|
|
48
|
+
# - `Array<GraphQL::AnalysisError>` — Array of errors rescued during analysis
|
|
42
49
|
attr_reader :rescued_errors
|
|
43
50
|
|
|
44
51
|
def visit
|
|
@@ -48,23 +55,44 @@ module GraphQL
|
|
|
48
55
|
|
|
49
56
|
# Visit Helpers
|
|
50
57
|
|
|
51
|
-
#
|
|
52
|
-
#
|
|
58
|
+
# See [GraphQL::Query#arguments_for](rdoc-ref:GraphQL::Query#arguments_for)
|
|
59
|
+
#
|
|
60
|
+
# **Returns**
|
|
61
|
+
#
|
|
62
|
+
# - `GraphQL::Execution::Interpreter::Arguments` — Arguments for this node, merging default values, literal values and query variables
|
|
63
|
+
#
|
|
64
|
+
# :call-seq:
|
|
65
|
+
# arguments_for(ast_node, field_definition) -> GraphQL::Execution::Interpreter::Arguments
|
|
53
66
|
def arguments_for(ast_node, field_definition)
|
|
54
67
|
@query.arguments_for(ast_node, field_definition)
|
|
55
68
|
end
|
|
56
69
|
|
|
57
|
-
#
|
|
70
|
+
# **Returns**
|
|
71
|
+
#
|
|
72
|
+
# - `Boolean` — If the visitor is currently inside a fragment definition
|
|
73
|
+
#
|
|
74
|
+
# :call-seq:
|
|
75
|
+
# visiting_fragment_definition?() -> bool
|
|
58
76
|
def visiting_fragment_definition?
|
|
59
77
|
@in_fragment_def
|
|
60
78
|
end
|
|
61
79
|
|
|
62
|
-
#
|
|
80
|
+
# **Returns**
|
|
81
|
+
#
|
|
82
|
+
# - `Boolean` — If the current node should be skipped because of a skip or include directive
|
|
83
|
+
#
|
|
84
|
+
# :call-seq:
|
|
85
|
+
# skipping?() -> bool
|
|
63
86
|
def skipping?
|
|
64
87
|
@skipping
|
|
65
88
|
end
|
|
66
89
|
|
|
67
|
-
#
|
|
90
|
+
# **Returns**
|
|
91
|
+
#
|
|
92
|
+
# - `Array<String>` — The path to the response key for the current field
|
|
93
|
+
#
|
|
94
|
+
# :call-seq:
|
|
95
|
+
# response_path() -> Array[String]
|
|
68
96
|
def response_path
|
|
69
97
|
@response_path.dup
|
|
70
98
|
end
|
|
@@ -206,37 +234,72 @@ module GraphQL
|
|
|
206
234
|
@path.pop
|
|
207
235
|
end
|
|
208
236
|
|
|
209
|
-
#
|
|
237
|
+
# **Returns**
|
|
238
|
+
#
|
|
239
|
+
# - `GraphQL::BaseType` — The current object type
|
|
240
|
+
#
|
|
241
|
+
# :call-seq:
|
|
242
|
+
# type_definition() -> GraphQL::BaseType
|
|
210
243
|
def type_definition
|
|
211
244
|
@object_types.last
|
|
212
245
|
end
|
|
213
246
|
|
|
214
|
-
#
|
|
247
|
+
# **Returns**
|
|
248
|
+
#
|
|
249
|
+
# - `GraphQL::BaseType` — The type which the current type came from
|
|
250
|
+
#
|
|
251
|
+
# :call-seq:
|
|
252
|
+
# parent_type_definition() -> GraphQL::BaseType
|
|
215
253
|
def parent_type_definition
|
|
216
254
|
@object_types[-2]
|
|
217
255
|
end
|
|
218
256
|
|
|
219
|
-
#
|
|
257
|
+
# **Returns**
|
|
258
|
+
#
|
|
259
|
+
# - `GraphQL::Field, nil` — The most-recently-entered GraphQL::Field, if currently inside one
|
|
260
|
+
#
|
|
261
|
+
# :call-seq:
|
|
262
|
+
# field_definition() -> GraphQL::Field | nil
|
|
220
263
|
def field_definition
|
|
221
264
|
@field_definitions.last
|
|
222
265
|
end
|
|
223
266
|
|
|
224
|
-
#
|
|
267
|
+
# **Returns**
|
|
268
|
+
#
|
|
269
|
+
# - `GraphQL::Field, nil` — The GraphQL field which returned the object that the current field belongs to
|
|
270
|
+
#
|
|
271
|
+
# :call-seq:
|
|
272
|
+
# previous_field_definition() -> GraphQL::Field | nil
|
|
225
273
|
def previous_field_definition
|
|
226
274
|
@field_definitions[-2]
|
|
227
275
|
end
|
|
228
276
|
|
|
229
|
-
#
|
|
277
|
+
# **Returns**
|
|
278
|
+
#
|
|
279
|
+
# - `GraphQL::Directive, nil` — The most-recently-entered GraphQL::Directive, if currently inside one
|
|
280
|
+
#
|
|
281
|
+
# :call-seq:
|
|
282
|
+
# directive_definition() -> GraphQL::Directive | nil
|
|
230
283
|
def directive_definition
|
|
231
284
|
@directive_definitions.last
|
|
232
285
|
end
|
|
233
286
|
|
|
234
|
-
#
|
|
287
|
+
# **Returns**
|
|
288
|
+
#
|
|
289
|
+
# - `GraphQL::Argument, nil` — The most-recently-entered GraphQL::Argument, if currently inside one
|
|
290
|
+
#
|
|
291
|
+
# :call-seq:
|
|
292
|
+
# argument_definition() -> GraphQL::Argument | nil
|
|
235
293
|
def argument_definition
|
|
236
294
|
@argument_definitions.last
|
|
237
295
|
end
|
|
238
296
|
|
|
239
|
-
#
|
|
297
|
+
# **Returns**
|
|
298
|
+
#
|
|
299
|
+
# - `GraphQL::Argument, nil` — The previous GraphQL argument
|
|
300
|
+
#
|
|
301
|
+
# :call-seq:
|
|
302
|
+
# previous_argument_definition() -> GraphQL::Argument | nil
|
|
240
303
|
def previous_argument_definition
|
|
241
304
|
@argument_definitions[-2]
|
|
242
305
|
end
|
data/lib/graphql/analysis.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require "graphql/analysis/visitor"
|
|
3
4
|
require "graphql/analysis/analyzer"
|
|
4
5
|
require "graphql/analysis/field_usage"
|
|
@@ -21,9 +22,17 @@ module GraphQL
|
|
|
21
22
|
# Multiplex analyzers are ran for all queries, keeping state.
|
|
22
23
|
# Query analyzers are ran per query, without carrying state between queries.
|
|
23
24
|
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
25
|
+
# **Parameters**
|
|
26
|
+
#
|
|
27
|
+
# - `multiplex` (`GraphQL::Execution::Multiplex`)
|
|
28
|
+
# - `analyzers` (`Array<GraphQL::Analysis::Analyzer>`)
|
|
29
|
+
#
|
|
30
|
+
# **Returns**
|
|
31
|
+
#
|
|
32
|
+
# - `Array<Any>` — Results from multiplex analyzers
|
|
33
|
+
#
|
|
34
|
+
# :call-seq:
|
|
35
|
+
# analyze_multiplex(GraphQL::Execution::Multiplex multiplex, Array[GraphQL::Analysis::Analyzer] analyzers) -> Array[Any]
|
|
27
36
|
def analyze_multiplex(multiplex, analyzers)
|
|
28
37
|
multiplex_analyzers = analyzers.map { |analyzer| analyzer.new(multiplex) }
|
|
29
38
|
|
|
@@ -50,9 +59,17 @@ module GraphQL
|
|
|
50
59
|
end
|
|
51
60
|
end
|
|
52
61
|
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
62
|
+
# **Parameters**
|
|
63
|
+
#
|
|
64
|
+
# - `query` (`GraphQL::Query`)
|
|
65
|
+
# - `analyzers` (`Array<GraphQL::Analysis::Analyzer>`)
|
|
66
|
+
#
|
|
67
|
+
# **Returns**
|
|
68
|
+
#
|
|
69
|
+
# - `Array<Any>` — Results from those analyzers
|
|
70
|
+
#
|
|
71
|
+
# :call-seq:
|
|
72
|
+
# analyze_query(GraphQL::Query query, Array[GraphQL::Analysis::Analyzer] analyzers, multiplex_analyzers:) -> Array[Any]
|
|
56
73
|
def analyze_query(query, analyzers, multiplex_analyzers: [])
|
|
57
74
|
query.current_trace.analyze_query(query: query) do
|
|
58
75
|
query_analyzers = analyzers.map { |analyzer| analyzer.new(query) }
|
data/lib/graphql/autoload.rb
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
|
-
#
|
|
5
|
+
# See [GraphQL::Railtie](rdoc-ref:GraphQL::Railtie) for automatic Rails integration
|
|
6
|
+
#--
|
|
7
|
+
# @requires_ancestor: Module
|
|
5
8
|
module Autoload
|
|
6
9
|
# Register a constant named `const_name` to be loaded from `path`.
|
|
7
|
-
# This is like `Kernel#autoload` but it tracks the constants so they can be eager-loaded with
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
10
|
+
# This is like `Kernel#autoload` but it tracks the constants so they can be eager-loaded with [eager load!](rdoc-ref:#eager_load!)
|
|
11
|
+
#
|
|
12
|
+
# **Parameters**
|
|
13
|
+
#
|
|
14
|
+
# - `const_name` (`Symbol`)
|
|
15
|
+
# - `path` (`String`)
|
|
16
|
+
#
|
|
17
|
+
# **Returns**
|
|
18
|
+
#
|
|
19
|
+
# - `void`
|
|
20
|
+
#
|
|
21
|
+
# :call-seq:
|
|
22
|
+
# autoload(Symbol const_name, String path) -> void
|
|
11
23
|
def autoload(const_name, path)
|
|
12
24
|
@_eagerloaded_constants ||= []
|
|
13
25
|
@_eagerloaded_constants << const_name
|
|
@@ -16,7 +28,13 @@ module GraphQL
|
|
|
16
28
|
end
|
|
17
29
|
|
|
18
30
|
# Call this to load this constant's `autoload` dependents and continue calling recursively
|
|
19
|
-
#
|
|
31
|
+
#
|
|
32
|
+
# **Returns**
|
|
33
|
+
#
|
|
34
|
+
# - `void`
|
|
35
|
+
#
|
|
36
|
+
# :call-seq:
|
|
37
|
+
# eager_load!() -> void
|
|
20
38
|
def eager_load!
|
|
21
39
|
@_eager_loading = true
|
|
22
40
|
if @_eagerloaded_constants
|
|
@@ -30,7 +48,12 @@ module GraphQL
|
|
|
30
48
|
|
|
31
49
|
private
|
|
32
50
|
|
|
33
|
-
#
|
|
51
|
+
# **Returns**
|
|
52
|
+
#
|
|
53
|
+
# - `Boolean` — `true` if GraphQL-Ruby is currently eager-loading its constants
|
|
54
|
+
#
|
|
55
|
+
# :call-seq:
|
|
56
|
+
# eager_loading?() -> bool
|
|
34
57
|
def eager_loading?
|
|
35
58
|
@_eager_loading ||= false
|
|
36
59
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Backtrace
|
|
4
5
|
# A class for turning a context into a human-readable table or array
|
|
@@ -18,12 +19,22 @@ module GraphQL
|
|
|
18
19
|
@override_value = value
|
|
19
20
|
end
|
|
20
21
|
|
|
21
|
-
#
|
|
22
|
+
# **Returns**
|
|
23
|
+
#
|
|
24
|
+
# - `String` — A table layout of backtrace with metadata
|
|
25
|
+
#
|
|
26
|
+
# :call-seq:
|
|
27
|
+
# to_table() -> String
|
|
22
28
|
def to_table
|
|
23
29
|
@to_table ||= render_table(rows)
|
|
24
30
|
end
|
|
25
31
|
|
|
26
|
-
#
|
|
32
|
+
# **Returns**
|
|
33
|
+
#
|
|
34
|
+
# - `Array<String>` — An array of position + field name entries
|
|
35
|
+
#
|
|
36
|
+
# :call-seq:
|
|
37
|
+
# to_backtrace() -> Array[String]
|
|
27
38
|
def to_backtrace
|
|
28
39
|
@to_backtrace ||= begin
|
|
29
40
|
backtrace = rows.map { |r| "#{r[0]}: #{r[1]}" }
|
|
@@ -43,7 +54,7 @@ module GraphQL
|
|
|
43
54
|
result = runtime_inst.instance_variable_get(:@response)
|
|
44
55
|
rows = []
|
|
45
56
|
result_path = []
|
|
46
|
-
last_part = nil
|
|
57
|
+
last_part = nil #: untyped
|
|
47
58
|
path = @context.current_path
|
|
48
59
|
path.each do |path_part|
|
|
49
60
|
value = value_at(runtime_inst, result_path)
|
|
@@ -79,7 +90,7 @@ module GraphQL
|
|
|
79
90
|
end
|
|
80
91
|
|
|
81
92
|
object = result.graphql_application_value.object.inspect
|
|
82
|
-
ast_node = nil
|
|
93
|
+
ast_node = nil #: untyped
|
|
83
94
|
result.graphql_selections.each do |s|
|
|
84
95
|
found_ast_node = find_ast_node(s, last_part)
|
|
85
96
|
if found_ast_node
|
|
@@ -134,7 +145,12 @@ module GraphQL
|
|
|
134
145
|
nil
|
|
135
146
|
end
|
|
136
147
|
|
|
137
|
-
#
|
|
148
|
+
# **Returns**
|
|
149
|
+
#
|
|
150
|
+
# - `String`
|
|
151
|
+
#
|
|
152
|
+
# :call-seq:
|
|
153
|
+
# render_table(rows) -> String
|
|
138
154
|
def render_table(rows)
|
|
139
155
|
max = Array.new(HEADERS.length, MIN_COL_WIDTH)
|
|
140
156
|
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
class Backtrace
|
|
4
|
-
# When
|
|
5
|
+
# When [Backtrace](rdoc-ref:GraphQL::Backtrace) is enabled, raised errors are wrapped with [TracedError](rdoc-ref:GraphQL::Backtrace::TracedError).
|
|
5
6
|
class TracedError < GraphQL::Error
|
|
6
|
-
#
|
|
7
|
+
# **Returns**
|
|
8
|
+
#
|
|
9
|
+
# - `Array<String>` — Printable backtrace of GraphQL error context
|
|
7
10
|
attr_reader :graphql_backtrace
|
|
8
11
|
|
|
9
|
-
#
|
|
12
|
+
# **Returns**
|
|
13
|
+
#
|
|
14
|
+
# - `GraphQL::Query::Context` — The context at the field where the error was raised
|
|
10
15
|
attr_reader :context
|
|
11
16
|
|
|
12
17
|
MESSAGE_TEMPLATE = <<-MESSAGE
|
data/lib/graphql/backtrace.rb
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require "graphql/backtrace/table"
|
|
3
4
|
require "graphql/backtrace/traced_error"
|
|
4
5
|
module GraphQL
|
|
5
|
-
# Wrap unhandled errors with
|
|
6
|
+
# Wrap unhandled errors with [TracedError](rdoc-ref:TracedError).
|
|
6
7
|
#
|
|
7
|
-
#
|
|
8
|
-
# The underlying error is available as
|
|
8
|
+
# [TracedError](rdoc-ref:TracedError) provides a GraphQL backtrace with arguments and return values.
|
|
9
|
+
# The underlying error is available as `TracedError#cause`.
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
# use GraphQL::Backtrace
|
|
14
|
-
# end
|
|
15
|
-
# end
|
|
11
|
+
# **Examples**
|
|
12
|
+
#
|
|
13
|
+
# **Example: toggling backtrace annotation**
|
|
16
14
|
#
|
|
15
|
+
# ```ruby
|
|
16
|
+
# class MySchema < GraphQL::Schema
|
|
17
|
+
# if Rails.env.development? || Rails.env.test?
|
|
18
|
+
# use GraphQL::Backtrace
|
|
19
|
+
# end
|
|
20
|
+
# end
|
|
21
|
+
# ```
|
|
17
22
|
class Backtrace
|
|
18
23
|
include Enumerable
|
|
19
24
|
extend Forwardable
|
data/lib/graphql/current.rb
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
# This module exposes Fiber-level runtime information.
|
|
5
6
|
#
|
|
6
7
|
# It won't work across unrelated fibers, although it will work in child Fibers.
|
|
7
8
|
#
|
|
8
|
-
#
|
|
9
|
+
# **Examples**
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
-
# :namespaced_controller,
|
|
12
|
-
# :action,
|
|
13
|
-
# :job,
|
|
14
|
-
# # ...
|
|
15
|
-
# {
|
|
16
|
-
# # GraphQL runtime info:
|
|
17
|
-
# current_graphql_operation: -> { GraphQL::Current.operation_name },
|
|
18
|
-
# current_graphql_field: -> { GraphQL::Current.field&.path },
|
|
19
|
-
# current_dataloader_source: -> { GraphQL::Current.dataloader_source_class },
|
|
20
|
-
# # ...
|
|
21
|
-
# },
|
|
22
|
-
# ]
|
|
11
|
+
# **Example: Setting Up ActiveRecord::QueryLogs**
|
|
23
12
|
#
|
|
13
|
+
# ```ruby
|
|
14
|
+
# config.active_record.query_log_tags = [
|
|
15
|
+
# :namespaced_controller,
|
|
16
|
+
# :action,
|
|
17
|
+
# :job,
|
|
18
|
+
# # ...
|
|
19
|
+
# {
|
|
20
|
+
# # GraphQL runtime info:
|
|
21
|
+
# current_graphql_operation: -> { GraphQL::Current.operation_name },
|
|
22
|
+
# current_graphql_field: -> { GraphQL::Current.field&.path },
|
|
23
|
+
# current_dataloader_source: -> { GraphQL::Current.dataloader_source_class },
|
|
24
|
+
# # ...
|
|
25
|
+
# },
|
|
26
|
+
# ]
|
|
27
|
+
# ```
|
|
24
28
|
module Current
|
|
25
|
-
#
|
|
29
|
+
# **Returns**
|
|
30
|
+
#
|
|
31
|
+
# - `String, nil` — Comma-joined operation names for the currently-running `Execution::Multiplex`. `nil` if all operations are anonymous.
|
|
32
|
+
#
|
|
33
|
+
# :call-seq:
|
|
34
|
+
# operation_name() -> String | nil
|
|
26
35
|
def self.operation_name
|
|
27
36
|
if (m = Fiber[:__graphql_current_multiplex])
|
|
28
37
|
m.context[:__graphql_current_operation_name] ||= begin
|
|
@@ -38,8 +47,14 @@ module GraphQL
|
|
|
38
47
|
end
|
|
39
48
|
end
|
|
40
49
|
|
|
41
|
-
#
|
|
42
|
-
#
|
|
50
|
+
# See [Schema::Member::HasPath#path](rdoc-ref:GraphQL::Schema::Member::HasPath#path) for a string identifying this field
|
|
51
|
+
#
|
|
52
|
+
# **Returns**
|
|
53
|
+
#
|
|
54
|
+
# - `GraphQL::Field, nil` — The currently-running field, if there is one.
|
|
55
|
+
#
|
|
56
|
+
# :call-seq:
|
|
57
|
+
# field() -> GraphQL::Field | nil
|
|
43
58
|
def self.field
|
|
44
59
|
if (interpreter_info = Fiber[:__graphql_runtime_info])
|
|
45
60
|
interpreter_info.values&.first&.current_field
|
|
@@ -50,12 +65,22 @@ module GraphQL
|
|
|
50
65
|
end
|
|
51
66
|
end
|
|
52
67
|
|
|
53
|
-
#
|
|
68
|
+
# **Returns**
|
|
69
|
+
#
|
|
70
|
+
# - `Class, nil` — The currently-running [Dataloader::Source](rdoc-ref:Dataloader::Source) class, if there is one.
|
|
71
|
+
#
|
|
72
|
+
# :call-seq:
|
|
73
|
+
# dataloader_source_class() -> Class | nil
|
|
54
74
|
def self.dataloader_source_class
|
|
55
75
|
Fiber[:__graphql_current_dataloader_source]&.class
|
|
56
76
|
end
|
|
57
77
|
|
|
58
|
-
#
|
|
78
|
+
# **Returns**
|
|
79
|
+
#
|
|
80
|
+
# - `GraphQL::Dataloader::Source, nil` — The currently-running source, if there is one
|
|
81
|
+
#
|
|
82
|
+
# :call-seq:
|
|
83
|
+
# dataloader_source() -> GraphQL::Dataloader::Source | nil
|
|
59
84
|
def self.dataloader_source
|
|
60
85
|
Fiber[:__graphql_current_dataloader_source]
|
|
61
86
|
end
|
data/lib/graphql/dashboard.rb
CHANGED
|
@@ -1,40 +1,54 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require 'rails/engine'
|
|
3
4
|
require 'action_controller'
|
|
4
5
|
module Graphql
|
|
5
6
|
# `GraphQL::Dashboard` is a `Rails::Engine`-based dashboard for viewing metadata about your GraphQL schema.
|
|
6
7
|
#
|
|
7
8
|
# Pass the class name of your schema when mounting it.
|
|
8
|
-
#
|
|
9
|
+
# See [GraphQL::Tracing::DetailedTrace](rdoc-ref:GraphQL::Tracing::DetailedTrace) DetailedTrace for viewing production traces in the Dashboard
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
-
# mount GraphQL::Dashboard, at: "graphql_dashboard", schema: "MySchema"
|
|
11
|
+
# **Examples**
|
|
12
12
|
#
|
|
13
|
-
#
|
|
14
|
-
# mount GraphQL::Dashboard, at: "graphql_dashboard", schema: ["MySchema", "OtherSchema"]
|
|
13
|
+
# **Example: Mounting the Dashboard in your app**
|
|
15
14
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
15
|
+
# ```ruby
|
|
16
|
+
# mount GraphQL::Dashboard, at: "graphql_dashboard", schema: "MySchema"
|
|
17
|
+
# ```
|
|
18
|
+
#
|
|
19
|
+
# To allow selecting from multiple schemas with the `schema` query parameter:
|
|
20
|
+
#
|
|
21
|
+
# ```ruby
|
|
22
|
+
# mount GraphQL::Dashboard, at: "graphql_dashboard", schema: ["MySchema", "OtherSchema"]
|
|
23
|
+
# ```
|
|
23
24
|
#
|
|
24
|
-
#
|
|
25
|
-
# # config/initializers/graphql_dashboard.rb
|
|
26
|
-
# ActiveSupport.on_load(:graphql_dashboard_application_controller) do
|
|
27
|
-
# # context here is GraphQL::Dashboard::ApplicationController
|
|
25
|
+
# **Example: Authenticating the Dashboard with HTTP Basic Auth**
|
|
28
26
|
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
27
|
+
# ```ruby
|
|
28
|
+
# # config/initializers/graphql_dashboard.rb
|
|
29
|
+
# GraphQL::Dashboard.middleware.use(Rack::Auth::Basic) do |username, password|
|
|
30
|
+
# # Compare the provided username/password to an application setting:
|
|
31
|
+
# ActiveSupport::SecurityUtils.secure_compare(Rails.application.credentials.graphql_dashboard_username, username) &&
|
|
32
|
+
# ActiveSupport::SecurityUtils.secure_compare(Rails.application.credentials.graphql_dashboard_username, password)
|
|
33
|
+
# end
|
|
34
|
+
# ```
|
|
32
35
|
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
+
# **Example: Custom Rails authentication**
|
|
37
|
+
#
|
|
38
|
+
# ```ruby
|
|
39
|
+
# # config/initializers/graphql_dashboard.rb
|
|
40
|
+
# ActiveSupport.on_load(:graphql_dashboard_application_controller) do
|
|
41
|
+
# # context here is GraphQL::Dashboard::ApplicationController
|
|
42
|
+
#
|
|
43
|
+
# before_action do
|
|
44
|
+
# raise ActionController::RoutingError.new('Not Found') unless current_user&.admin?
|
|
36
45
|
# end
|
|
37
46
|
#
|
|
47
|
+
# def current_user
|
|
48
|
+
# # load current user
|
|
49
|
+
# end
|
|
50
|
+
# end
|
|
51
|
+
# ```
|
|
38
52
|
class Dashboard < Rails::Engine
|
|
39
53
|
engine_name "graphql_dashboard"
|
|
40
54
|
isolate_namespace(Graphql::Dashboard)
|