graphql 1.9.18 → 1.13.24
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/lib/generators/graphql/core.rb +21 -10
- data/lib/generators/graphql/enum_generator.rb +4 -10
- data/lib/generators/graphql/field_extractor.rb +31 -0
- data/lib/generators/graphql/input_generator.rb +50 -0
- data/lib/generators/graphql/install/mutation_root_generator.rb +34 -0
- data/lib/generators/graphql/{templates → install/templates}/base_mutation.erb +2 -0
- data/lib/generators/graphql/{templates → install/templates}/mutation_type.erb +2 -0
- data/lib/generators/graphql/install_generator.rb +44 -7
- data/lib/generators/graphql/interface_generator.rb +7 -7
- data/lib/generators/graphql/loader_generator.rb +1 -0
- data/lib/generators/graphql/mutation_create_generator.rb +22 -0
- data/lib/generators/graphql/mutation_delete_generator.rb +22 -0
- data/lib/generators/graphql/mutation_generator.rb +6 -30
- data/lib/generators/graphql/mutation_update_generator.rb +22 -0
- data/lib/generators/graphql/object_generator.rb +28 -12
- data/lib/generators/graphql/orm_mutations_base.rb +40 -0
- data/lib/generators/graphql/relay.rb +63 -0
- data/lib/generators/graphql/relay_generator.rb +21 -0
- data/lib/generators/graphql/scalar_generator.rb +4 -2
- data/lib/generators/graphql/templates/base_argument.erb +2 -0
- data/lib/generators/graphql/templates/base_connection.erb +8 -0
- data/lib/generators/graphql/templates/base_edge.erb +8 -0
- data/lib/generators/graphql/templates/base_enum.erb +2 -0
- data/lib/generators/graphql/templates/base_field.erb +2 -0
- data/lib/generators/graphql/templates/base_input_object.erb +2 -0
- data/lib/generators/graphql/templates/base_interface.erb +2 -0
- data/lib/generators/graphql/templates/base_object.erb +2 -0
- data/lib/generators/graphql/templates/base_scalar.erb +2 -0
- data/lib/generators/graphql/templates/base_union.erb +2 -0
- data/lib/generators/graphql/templates/enum.erb +7 -1
- data/lib/generators/graphql/templates/graphql_controller.erb +16 -12
- data/lib/generators/graphql/templates/input.erb +9 -0
- data/lib/generators/graphql/templates/interface.erb +6 -2
- data/lib/generators/graphql/templates/loader.erb +2 -0
- data/lib/generators/graphql/templates/mutation.erb +3 -1
- data/lib/generators/graphql/templates/mutation_create.erb +20 -0
- data/lib/generators/graphql/templates/mutation_delete.erb +20 -0
- data/lib/generators/graphql/templates/mutation_update.erb +21 -0
- data/lib/generators/graphql/templates/node_type.erb +9 -0
- data/lib/generators/graphql/templates/object.erb +7 -3
- data/lib/generators/graphql/templates/query_type.erb +3 -3
- data/lib/generators/graphql/templates/scalar.erb +5 -1
- data/lib/generators/graphql/templates/schema.erb +22 -27
- data/lib/generators/graphql/templates/union.erb +6 -2
- data/lib/generators/graphql/type_generator.rb +47 -10
- data/lib/generators/graphql/union_generator.rb +5 -5
- data/lib/graphql/analysis/analyze_query.rb +7 -0
- data/lib/graphql/analysis/ast/field_usage.rb +29 -2
- data/lib/graphql/analysis/ast/query_complexity.rb +174 -67
- data/lib/graphql/analysis/ast/visitor.rb +16 -7
- data/lib/graphql/analysis/ast.rb +21 -11
- data/lib/graphql/argument.rb +8 -36
- data/lib/graphql/backtrace/inspect_result.rb +0 -1
- data/lib/graphql/backtrace/legacy_tracer.rb +56 -0
- data/lib/graphql/backtrace/table.rb +44 -5
- data/lib/graphql/backtrace/traced_error.rb +0 -1
- data/lib/graphql/backtrace/tracer.rb +40 -9
- data/lib/graphql/backtrace.rb +28 -19
- data/lib/graphql/backwards_compatibility.rb +2 -1
- data/lib/graphql/base_type.rb +10 -4
- data/lib/graphql/boolean_type.rb +1 -1
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +2 -2
- data/lib/graphql/compatibility/execution_specification.rb +1 -0
- data/lib/graphql/compatibility/lazy_execution_specification.rb +2 -0
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +5 -9
- data/lib/graphql/compatibility/query_parser_specification.rb +2 -0
- data/lib/graphql/compatibility/schema_parser_specification.rb +2 -0
- data/lib/graphql/dataloader/null_dataloader.rb +22 -0
- data/lib/graphql/dataloader/request.rb +19 -0
- data/lib/graphql/dataloader/request_all.rb +19 -0
- data/lib/graphql/dataloader/source.rb +155 -0
- data/lib/graphql/dataloader.rb +308 -0
- data/lib/graphql/date_encoding_error.rb +16 -0
- data/lib/graphql/define/assign_enum_value.rb +1 -1
- data/lib/graphql/define/assign_global_id_field.rb +2 -2
- data/lib/graphql/define/assign_object_field.rb +1 -1
- data/lib/graphql/define/defined_object_proxy.rb +5 -8
- data/lib/graphql/define/instance_definable.rb +60 -110
- data/lib/graphql/define/type_definer.rb +5 -5
- data/lib/graphql/deprecated_dsl.rb +18 -5
- data/lib/graphql/deprecation.rb +9 -0
- data/lib/graphql/directive/deprecated_directive.rb +1 -12
- data/lib/graphql/directive/include_directive.rb +1 -1
- data/lib/graphql/directive/skip_directive.rb +1 -1
- data/lib/graphql/directive.rb +9 -6
- data/lib/graphql/enum_type.rb +14 -74
- data/lib/graphql/execution/directive_checks.rb +2 -2
- data/lib/graphql/execution/errors.rb +110 -8
- data/lib/graphql/execution/execute.rb +8 -1
- data/lib/graphql/execution/instrumentation.rb +1 -1
- data/lib/graphql/execution/interpreter/argument_value.rb +28 -0
- data/lib/graphql/execution/interpreter/arguments.rb +88 -0
- data/lib/graphql/execution/interpreter/arguments_cache.rb +105 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +18 -0
- data/lib/graphql/execution/interpreter/resolve.rb +37 -25
- data/lib/graphql/execution/interpreter/runtime.rb +721 -386
- data/lib/graphql/execution/interpreter.rb +42 -19
- data/lib/graphql/execution/lazy/lazy_method_map.rb +4 -0
- data/lib/graphql/execution/lazy.rb +5 -1
- data/lib/graphql/execution/lookahead.rb +39 -114
- data/lib/graphql/execution/multiplex.rb +50 -25
- data/lib/graphql/field.rb +15 -119
- data/lib/graphql/filter.rb +1 -1
- data/lib/graphql/float_type.rb +1 -1
- data/lib/graphql/function.rb +5 -30
- data/lib/graphql/id_type.rb +1 -1
- data/lib/graphql/input_object_type.rb +9 -25
- data/lib/graphql/int_type.rb +1 -1
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +18 -2
- data/lib/graphql/interface_type.rb +10 -24
- data/lib/graphql/internal_representation/document.rb +2 -2
- data/lib/graphql/internal_representation/rewrite.rb +1 -1
- data/lib/graphql/internal_representation/scope.rb +2 -2
- data/lib/graphql/internal_representation/visit.rb +2 -2
- data/lib/graphql/introspection/base_object.rb +2 -5
- data/lib/graphql/introspection/directive_location_enum.rb +2 -2
- data/lib/graphql/introspection/directive_type.rb +12 -6
- data/lib/graphql/introspection/entry_points.rb +9 -9
- data/lib/graphql/introspection/enum_value_type.rb +2 -2
- data/lib/graphql/introspection/field_type.rb +9 -5
- data/lib/graphql/introspection/input_value_type.rb +41 -11
- data/lib/graphql/introspection/introspection_query.rb +6 -92
- data/lib/graphql/introspection/schema_type.rb +12 -12
- data/lib/graphql/introspection/type_type.rb +27 -17
- data/lib/graphql/introspection.rb +99 -0
- data/lib/graphql/invalid_null_error.rb +18 -0
- data/lib/graphql/language/block_string.rb +20 -5
- data/lib/graphql/language/cache.rb +37 -0
- data/lib/graphql/language/definition_slice.rb +21 -10
- data/lib/graphql/language/document_from_schema_definition.rb +116 -63
- data/lib/graphql/language/lexer.rb +53 -27
- data/lib/graphql/language/lexer.rl +5 -3
- data/lib/graphql/language/nodes.rb +67 -93
- data/lib/graphql/language/parser.rb +929 -896
- data/lib/graphql/language/parser.y +125 -102
- data/lib/graphql/language/printer.rb +11 -2
- data/lib/graphql/language/sanitized_printer.rb +222 -0
- data/lib/graphql/language/token.rb +0 -4
- data/lib/graphql/language/visitor.rb +2 -2
- data/lib/graphql/language.rb +3 -1
- data/lib/graphql/name_validator.rb +2 -7
- data/lib/graphql/non_null_type.rb +0 -10
- data/lib/graphql/object_type.rb +47 -58
- data/lib/graphql/pagination/active_record_relation_connection.rb +85 -0
- data/lib/graphql/pagination/array_connection.rb +77 -0
- data/lib/graphql/pagination/connection.rb +226 -0
- data/lib/graphql/pagination/connections.rb +160 -0
- data/lib/graphql/pagination/mongoid_relation_connection.rb +25 -0
- data/lib/graphql/pagination/relation_connection.rb +226 -0
- data/lib/graphql/pagination/sequel_dataset_connection.rb +28 -0
- data/lib/graphql/pagination.rb +6 -0
- data/lib/graphql/parse_error.rb +0 -1
- data/lib/graphql/query/arguments.rb +6 -4
- data/lib/graphql/query/arguments_cache.rb +1 -2
- data/lib/graphql/query/context.rb +52 -7
- data/lib/graphql/query/executor.rb +0 -1
- data/lib/graphql/query/fingerprint.rb +26 -0
- data/lib/graphql/query/input_validation_result.rb +32 -6
- data/lib/graphql/query/literal_input.rb +31 -11
- data/lib/graphql/query/null_context.rb +24 -8
- data/lib/graphql/query/serial_execution/field_resolution.rb +1 -1
- data/lib/graphql/query/serial_execution.rb +1 -0
- data/lib/graphql/query/validation_pipeline.rb +6 -4
- data/lib/graphql/query/variable_validation_error.rb +3 -3
- data/lib/graphql/query/variables.rb +50 -10
- data/lib/graphql/query.rb +77 -18
- data/lib/graphql/railtie.rb +9 -1
- data/lib/graphql/rake_task/validate.rb +3 -0
- data/lib/graphql/rake_task.rb +12 -9
- data/lib/graphql/relay/array_connection.rb +10 -12
- data/lib/graphql/relay/base_connection.rb +30 -13
- data/lib/graphql/relay/connection_instrumentation.rb +4 -4
- data/lib/graphql/relay/connection_type.rb +18 -4
- data/lib/graphql/relay/edge_type.rb +1 -0
- data/lib/graphql/relay/edges_instrumentation.rb +1 -2
- data/lib/graphql/relay/global_id_resolve.rb +1 -2
- data/lib/graphql/relay/mutation.rb +3 -87
- data/lib/graphql/relay/node.rb +3 -0
- data/lib/graphql/relay/page_info.rb +1 -1
- data/lib/graphql/relay/range_add.rb +27 -9
- data/lib/graphql/relay/relation_connection.rb +8 -10
- data/lib/graphql/relay/type_extensions.rb +2 -0
- data/lib/graphql/rubocop/graphql/base_cop.rb +36 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +43 -0
- data/lib/graphql/rubocop/graphql/default_required_true.rb +43 -0
- data/lib/graphql/rubocop.rb +4 -0
- data/lib/graphql/scalar_type.rb +18 -60
- data/lib/graphql/schema/addition.rb +247 -0
- data/lib/graphql/schema/argument.rb +274 -18
- data/lib/graphql/schema/base_64_encoder.rb +2 -0
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -1
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +13 -5
- data/lib/graphql/schema/build_from_definition.rb +320 -219
- data/lib/graphql/schema/built_in_types.rb +5 -5
- data/lib/graphql/schema/default_type_error.rb +2 -0
- data/lib/graphql/schema/directive/deprecated.rb +18 -0
- data/lib/graphql/schema/directive/feature.rb +1 -1
- data/lib/graphql/schema/directive/flagged.rb +57 -0
- data/lib/graphql/schema/directive/include.rb +2 -2
- data/lib/graphql/schema/directive/skip.rb +2 -2
- data/lib/graphql/schema/directive/transform.rb +14 -2
- data/lib/graphql/schema/directive.rb +130 -6
- data/lib/graphql/schema/enum.rb +121 -12
- data/lib/graphql/schema/enum_value.rb +24 -7
- data/lib/graphql/schema/field/connection_extension.rb +46 -20
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +465 -181
- data/lib/graphql/schema/field_extension.rb +89 -2
- data/lib/graphql/schema/find_inherited_value.rb +17 -1
- data/lib/graphql/schema/finder.rb +16 -14
- data/lib/graphql/schema/input_object.rb +172 -37
- data/lib/graphql/schema/interface.rb +39 -25
- data/lib/graphql/schema/introspection_system.rb +106 -38
- data/lib/graphql/schema/late_bound_type.rb +3 -2
- data/lib/graphql/schema/list.rb +65 -1
- data/lib/graphql/schema/loader.rb +145 -102
- data/lib/graphql/schema/member/accepts_definition.rb +15 -3
- data/lib/graphql/schema/member/base_dsl_methods.rb +34 -28
- data/lib/graphql/schema/member/build_type.rb +19 -8
- data/lib/graphql/schema/member/cached_graphql_definition.rb +34 -2
- data/lib/graphql/schema/member/has_arguments.rb +206 -13
- data/lib/graphql/schema/member/has_ast_node.rb +20 -0
- data/lib/graphql/schema/member/has_deprecation_reason.rb +25 -0
- data/lib/graphql/schema/member/has_directives.rb +98 -0
- data/lib/graphql/schema/member/has_fields.rb +97 -32
- data/lib/graphql/schema/member/has_interfaces.rb +100 -0
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +15 -0
- data/lib/graphql/schema/member/has_validators.rb +31 -0
- data/lib/graphql/schema/member/instrumentation.rb +0 -1
- data/lib/graphql/schema/member/type_system_helpers.rb +3 -3
- data/lib/graphql/schema/member/validates_input.rb +33 -0
- data/lib/graphql/schema/member.rb +11 -0
- data/lib/graphql/schema/middleware_chain.rb +1 -1
- data/lib/graphql/schema/mutation.rb +4 -0
- data/lib/graphql/schema/non_null.rb +37 -1
- data/lib/graphql/schema/object.rb +51 -38
- data/lib/graphql/schema/possible_types.rb +9 -4
- data/lib/graphql/schema/printer.rb +16 -35
- data/lib/graphql/schema/relay_classic_mutation.rb +40 -4
- data/lib/graphql/schema/resolver/has_payload_type.rb +34 -4
- data/lib/graphql/schema/resolver.rb +133 -79
- data/lib/graphql/schema/scalar.rb +43 -3
- data/lib/graphql/schema/subscription.rb +57 -21
- data/lib/graphql/schema/timeout.rb +29 -15
- data/lib/graphql/schema/timeout_middleware.rb +3 -1
- data/lib/graphql/schema/traversal.rb +2 -2
- data/lib/graphql/schema/type_expression.rb +21 -13
- data/lib/graphql/schema/type_membership.rb +19 -5
- data/lib/graphql/schema/union.rb +44 -3
- data/lib/graphql/schema/unique_within_type.rb +1 -2
- data/lib/graphql/schema/validation.rb +14 -4
- data/lib/graphql/schema/validator/allow_blank_validator.rb +29 -0
- data/lib/graphql/schema/validator/allow_null_validator.rb +26 -0
- data/lib/graphql/schema/validator/exclusion_validator.rb +33 -0
- data/lib/graphql/schema/validator/format_validator.rb +48 -0
- data/lib/graphql/schema/validator/inclusion_validator.rb +35 -0
- data/lib/graphql/schema/validator/length_validator.rb +59 -0
- data/lib/graphql/schema/validator/numericality_validator.rb +82 -0
- data/lib/graphql/schema/validator/required_validator.rb +82 -0
- data/lib/graphql/schema/validator.rb +171 -0
- data/lib/graphql/schema/warden.rb +193 -34
- data/lib/graphql/schema.rb +882 -247
- data/lib/graphql/static_validation/all_rules.rb +2 -0
- data/lib/graphql/static_validation/base_visitor.rb +17 -10
- data/lib/graphql/static_validation/definition_dependencies.rb +0 -1
- data/lib/graphql/static_validation/error.rb +3 -1
- data/lib/graphql/static_validation/literal_validator.rb +51 -26
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +45 -83
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +22 -6
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +35 -26
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +4 -2
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +1 -1
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +2 -2
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +4 -4
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +5 -5
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +94 -51
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +25 -4
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +2 -2
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +30 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +30 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +17 -0
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +26 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -2
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +9 -10
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +1 -1
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +12 -13
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +19 -14
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +5 -3
- data/lib/graphql/static_validation/type_stack.rb +2 -2
- data/lib/graphql/static_validation/validation_context.rb +13 -3
- data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
- data/lib/graphql/static_validation/validator.rb +43 -9
- data/lib/graphql/static_validation.rb +1 -0
- data/lib/graphql/string_encoding_error.rb +13 -3
- data/lib/graphql/string_type.rb +1 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +123 -22
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +81 -0
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +21 -0
- data/lib/graphql/subscriptions/event.rb +84 -30
- data/lib/graphql/subscriptions/instrumentation.rb +10 -6
- data/lib/graphql/subscriptions/serialize.rb +53 -6
- data/lib/graphql/subscriptions/subscription_root.rb +15 -5
- data/lib/graphql/subscriptions.rb +117 -49
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +8 -17
- data/lib/graphql/tracing/appoptics_tracing.rb +173 -0
- data/lib/graphql/tracing/appsignal_tracing.rb +23 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +32 -15
- data/lib/graphql/tracing/new_relic_tracing.rb +9 -12
- data/lib/graphql/tracing/notifications_tracing.rb +59 -0
- data/lib/graphql/tracing/platform_tracing.rb +66 -10
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +4 -1
- data/lib/graphql/tracing/prometheus_tracing.rb +8 -0
- data/lib/graphql/tracing/scout_tracing.rb +19 -0
- data/lib/graphql/tracing/skylight_tracing.rb +9 -1
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing.rb +15 -35
- data/lib/graphql/types/big_int.rb +5 -1
- data/lib/graphql/types/int.rb +10 -3
- data/lib/graphql/types/iso_8601_date.rb +16 -8
- data/lib/graphql/types/iso_8601_date_time.rb +32 -10
- data/lib/graphql/types/relay/base_connection.rb +6 -88
- data/lib/graphql/types/relay/base_edge.rb +2 -34
- data/lib/graphql/types/relay/connection_behaviors.rb +174 -0
- data/lib/graphql/types/relay/default_relay.rb +31 -0
- data/lib/graphql/types/relay/edge_behaviors.rb +64 -0
- data/lib/graphql/types/relay/has_node_field.rb +41 -0
- data/lib/graphql/types/relay/has_nodes_field.rb +41 -0
- data/lib/graphql/types/relay/node.rb +2 -4
- data/lib/graphql/types/relay/node_behaviors.rb +15 -0
- data/lib/graphql/types/relay/node_field.rb +3 -22
- data/lib/graphql/types/relay/nodes_field.rb +16 -18
- data/lib/graphql/types/relay/page_info.rb +2 -14
- data/lib/graphql/types/relay/page_info_behaviors.rb +25 -0
- data/lib/graphql/types/relay.rb +11 -3
- data/lib/graphql/types/string.rb +8 -2
- data/lib/graphql/unauthorized_error.rb +2 -2
- data/lib/graphql/union_type.rb +5 -25
- data/lib/graphql/unresolved_type_error.rb +2 -2
- data/lib/graphql/upgrader/member.rb +1 -0
- data/lib/graphql/upgrader/schema.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +87 -31
- data/readme.md +3 -6
- metadata +126 -124
- data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
- data/lib/graphql/literal_validation_error.rb +0 -6
- data/lib/graphql/types/relay/base_field.rb +0 -22
- data/lib/graphql/types/relay/base_interface.rb +0 -29
- data/lib/graphql/types/relay/base_object.rb +0 -26
data/lib/graphql/function.rb
CHANGED
|
@@ -1,36 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
module GraphQL
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# Class-level values defined with the DSL will be inherited,
|
|
6
|
-
# so {GraphQL::Function}s can extend one another.
|
|
7
|
-
#
|
|
8
|
-
# It's OK to override the instance methods here in order to customize behavior of instances.
|
|
9
|
-
#
|
|
10
|
-
# @example A reusable GraphQL::Function attached as a field
|
|
11
|
-
# class FindRecord < GraphQL::Function
|
|
12
|
-
# attr_reader :type
|
|
13
|
-
#
|
|
14
|
-
# def initialize(model:, type:)
|
|
15
|
-
# @model = model
|
|
16
|
-
# @type = type
|
|
17
|
-
# end
|
|
18
|
-
#
|
|
19
|
-
# argument :id, GraphQL::ID_TYPE
|
|
20
|
-
#
|
|
21
|
-
# def call(obj, args, ctx)
|
|
22
|
-
# @model.find(args.id)
|
|
23
|
-
# end
|
|
24
|
-
# end
|
|
25
|
-
#
|
|
26
|
-
# QueryType = GraphQL::ObjectType.define do
|
|
27
|
-
# name "Query"
|
|
28
|
-
# field :post, function: FindRecord.new(model: Post, type: PostType)
|
|
29
|
-
# field :comment, function: FindRecord.new(model: Comment, type: CommentType)
|
|
30
|
-
# end
|
|
31
|
-
#
|
|
32
|
-
# @see {GraphQL::Schema::Resolver} for a replacement for `GraphQL::Function`
|
|
3
|
+
# @api deprecated
|
|
33
4
|
class Function
|
|
5
|
+
def self.inherited(subclass)
|
|
6
|
+
GraphQL::Deprecation.warn "GraphQL::Function (used for #{subclass}) will be removed from GraphQL-Ruby 2.0, please upgrade to resolvers: https://graphql-ruby.org/fields/resolvers.html"
|
|
7
|
+
end
|
|
8
|
+
|
|
34
9
|
# @return [Hash<String => GraphQL::Argument>] Arguments, keyed by name
|
|
35
10
|
def arguments
|
|
36
11
|
self.class.arguments
|
data/lib/graphql/id_type.rb
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
GraphQL::ID_TYPE = GraphQL::Types::ID.graphql_definition
|
|
2
|
+
GraphQL::ID_TYPE = GraphQL::Types::ID.graphql_definition(silence_deprecation_warning: true)
|
|
@@ -1,30 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
module GraphQL
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# Input objects have _arguments_ which are identical to {GraphQL::Field} arguments.
|
|
6
|
-
# They map names to types and support default values.
|
|
7
|
-
# Their input types can be any input types, including {InputObjectType}s.
|
|
8
|
-
#
|
|
9
|
-
# @example An input type with name and number
|
|
10
|
-
# PlayerInput = GraphQL::InputObjectType.define do
|
|
11
|
-
# name("Player")
|
|
12
|
-
# argument :name, !types.String
|
|
13
|
-
# argument :number, !types.Int
|
|
14
|
-
# end
|
|
15
|
-
#
|
|
16
|
-
# In a `resolve` function, you can access the values by making nested lookups on `args`.
|
|
17
|
-
#
|
|
18
|
-
# @example Accessing input values in a resolve function
|
|
19
|
-
# resolve ->(obj, args, ctx) {
|
|
20
|
-
# args[:player][:name] # => "Tony Gwynn"
|
|
21
|
-
# args[:player][:number] # => 19
|
|
22
|
-
# args[:player].to_h # { "name" => "Tony Gwynn", "number" => 19 }
|
|
23
|
-
# # ...
|
|
24
|
-
# }
|
|
25
|
-
#
|
|
3
|
+
# @api deprecated
|
|
26
4
|
class InputObjectType < GraphQL::BaseType
|
|
27
|
-
|
|
5
|
+
extend Define::InstanceDefinable::DeprecatedDefine
|
|
6
|
+
|
|
7
|
+
deprecated_accepts_definitions(
|
|
28
8
|
:arguments, :mutation,
|
|
29
9
|
input_field: GraphQL::Define::AssignArgument,
|
|
30
10
|
argument: GraphQL::Define::AssignArgument
|
|
@@ -80,6 +60,10 @@ module GraphQL
|
|
|
80
60
|
result
|
|
81
61
|
end
|
|
82
62
|
|
|
63
|
+
def get_argument(argument_name)
|
|
64
|
+
arguments[argument_name]
|
|
65
|
+
end
|
|
66
|
+
|
|
83
67
|
private
|
|
84
68
|
|
|
85
69
|
def coerce_non_null_input(value, ctx)
|
|
@@ -136,7 +120,7 @@ module GraphQL
|
|
|
136
120
|
# Items in the input that are unexpected
|
|
137
121
|
input.each do |name, value|
|
|
138
122
|
if visible_arguments_map[name].nil?
|
|
139
|
-
result.add_problem("Field is not defined on #{self.
|
|
123
|
+
result.add_problem("Field is not defined on #{self.graphql_name}", [name])
|
|
140
124
|
end
|
|
141
125
|
end
|
|
142
126
|
|
data/lib/graphql/int_type.rb
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
GraphQL::INT_TYPE = GraphQL::Types::Int.graphql_definition
|
|
2
|
+
GraphQL::INT_TYPE = GraphQL::Types::Int.graphql_definition(silence_deprecation_warning: true)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module GraphQL
|
|
3
|
+
# This error is raised when `Types::Int` is given an input value outside of 32-bit integer range.
|
|
4
|
+
#
|
|
5
|
+
# For really big integer values, consider `GraphQL::Types::BigInt`
|
|
6
|
+
#
|
|
7
|
+
# @see GraphQL::Types::Int which raises this error
|
|
8
|
+
class IntegerDecodingError < GraphQL::RuntimeTypeError
|
|
9
|
+
# The value which couldn't be decoded
|
|
10
|
+
attr_reader :integer_value
|
|
11
|
+
|
|
12
|
+
def initialize(value)
|
|
13
|
+
@integer_value = value
|
|
14
|
+
super("Integer out of bounds: #{value}. \nConsider using GraphQL::Types::BigInt instead.")
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -12,9 +12,25 @@ module GraphQL
|
|
|
12
12
|
# The value which couldn't be encoded
|
|
13
13
|
attr_reader :integer_value
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
# @return [GraphQL::Schema::Field] The field that returned a too-big integer
|
|
16
|
+
attr_reader :field
|
|
17
|
+
|
|
18
|
+
# @return [Array<String, Integer>] Where the field appeared in the GraphQL response
|
|
19
|
+
attr_reader :path
|
|
20
|
+
|
|
21
|
+
def initialize(value, context:)
|
|
16
22
|
@integer_value = value
|
|
17
|
-
|
|
23
|
+
@field = context[:current_field]
|
|
24
|
+
@path = context[:current_path]
|
|
25
|
+
message = "Integer out of bounds: #{value}".dup
|
|
26
|
+
if @path
|
|
27
|
+
message << " @ #{@path.join(".")}"
|
|
28
|
+
end
|
|
29
|
+
if @field
|
|
30
|
+
message << " (#{@field.path})"
|
|
31
|
+
end
|
|
32
|
+
message << ". Consider using ID or GraphQL::Types::BigInt instead."
|
|
33
|
+
super(message)
|
|
18
34
|
end
|
|
19
35
|
end
|
|
20
36
|
end
|
|
@@ -1,31 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
module GraphQL
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# Interfaces can have fields, defined with `field`, just like an object type.
|
|
6
|
-
#
|
|
7
|
-
# Objects which implement this field _inherit_ field definitions from the interface.
|
|
8
|
-
# An object type can override the inherited definition by redefining that field.
|
|
9
|
-
#
|
|
10
|
-
# @example An interface with three fields
|
|
11
|
-
# DeviceInterface = GraphQL::InterfaceType.define do
|
|
12
|
-
# name("Device")
|
|
13
|
-
# description("Hardware devices for computing")
|
|
14
|
-
#
|
|
15
|
-
# field :ram, types.String
|
|
16
|
-
# field :processor, ProcessorType
|
|
17
|
-
# field :release_year, types.Int
|
|
18
|
-
# end
|
|
19
|
-
#
|
|
20
|
-
# @example Implementing an interface with an object type
|
|
21
|
-
# Laptoptype = GraphQL::ObjectType.define do
|
|
22
|
-
# interfaces [DeviceInterface]
|
|
23
|
-
# end
|
|
24
|
-
#
|
|
3
|
+
# @api deprecated
|
|
25
4
|
class InterfaceType < GraphQL::BaseType
|
|
26
|
-
|
|
5
|
+
extend Define::InstanceDefinable::DeprecatedDefine
|
|
6
|
+
|
|
7
|
+
deprecated_accepts_definitions :fields, :orphan_types, :resolve_type, field: GraphQL::Define::AssignObjectField
|
|
27
8
|
|
|
28
9
|
attr_accessor :fields, :orphan_types, :resolve_type_proc
|
|
10
|
+
attr_writer :type_membership_class
|
|
29
11
|
ensure_defined :fields, :orphan_types, :resolve_type_proc, :resolve_type
|
|
30
12
|
|
|
31
13
|
def initialize
|
|
@@ -71,7 +53,7 @@ module GraphQL
|
|
|
71
53
|
# @return [GraphQL::ObjectType, nil] The type named `type_name` if it exists and implements this {InterfaceType}, (else `nil`)
|
|
72
54
|
def get_possible_type(type_name, ctx)
|
|
73
55
|
type = ctx.query.get_type(type_name)
|
|
74
|
-
type if type && ctx.query.
|
|
56
|
+
type if type && ctx.query.warden.possible_types(self).include?(type)
|
|
75
57
|
end
|
|
76
58
|
|
|
77
59
|
# Check if a type is a possible type of this {InterfaceType}
|
|
@@ -82,5 +64,9 @@ module GraphQL
|
|
|
82
64
|
type_name = type.is_a?(String) ? type : type.graphql_name
|
|
83
65
|
!get_possible_type(type_name, ctx).nil?
|
|
84
66
|
end
|
|
67
|
+
|
|
68
|
+
def type_membership_class
|
|
69
|
+
@type_membership_class || GraphQL::Schema::TypeMembership
|
|
70
|
+
end
|
|
85
71
|
end
|
|
86
72
|
end
|
|
@@ -14,12 +14,12 @@ module GraphQL
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def [](key)
|
|
17
|
-
warn "#{self.class}#[] is deprecated; use `operation_definitions[]` instead"
|
|
17
|
+
GraphQL::Deprecation.warn "#{self.class}#[] is deprecated; use `operation_definitions[]` instead"
|
|
18
18
|
operation_definitions[key]
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def each(&block)
|
|
22
|
-
warn "#{self.class}#each is deprecated; use `operation_definitions.each` instead"
|
|
22
|
+
GraphQL::Deprecation.warn "#{self.class}#each is deprecated; use `operation_definitions.each` instead"
|
|
23
23
|
operation_definitions.each(&block)
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -60,7 +60,7 @@ module GraphQL
|
|
|
60
60
|
|
|
61
61
|
# @return [Hash<String, Node>] Roots of this query
|
|
62
62
|
def operations
|
|
63
|
-
warn "#{self.class}#operations is deprecated; use `document.operation_definitions` instead"
|
|
63
|
+
GraphQL::Deprecation.warn "#{self.class}#operations is deprecated; use `document.operation_definitions` instead"
|
|
64
64
|
@document.operation_definitions
|
|
65
65
|
end
|
|
66
66
|
|
|
@@ -66,11 +66,11 @@ module GraphQL
|
|
|
66
66
|
# Call the block for each type in `self`.
|
|
67
67
|
# This uses the simplest possible expression of `self`,
|
|
68
68
|
# so if this scope is defined by an abstract type, it gets yielded.
|
|
69
|
-
def each
|
|
69
|
+
def each(&block)
|
|
70
70
|
if @abstract_type
|
|
71
71
|
yield(@type)
|
|
72
72
|
else
|
|
73
|
-
@types.each
|
|
73
|
+
@types.each(&block)
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
@@ -23,11 +23,11 @@ module GraphQL
|
|
|
23
23
|
|
|
24
24
|
# Traverse a node in a rewritten query tree,
|
|
25
25
|
# visiting the node itself and each of its typed children.
|
|
26
|
-
def each_node(node)
|
|
26
|
+
def each_node(node, &block)
|
|
27
27
|
yield(node)
|
|
28
28
|
node.typed_children.each do |obj_type, children|
|
|
29
29
|
children.each do |name, node|
|
|
30
|
-
each_node(node
|
|
30
|
+
each_node(node, &block)
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
module GraphQL
|
|
3
3
|
module Introspection
|
|
4
4
|
class BaseObject < GraphQL::Schema::Object
|
|
5
|
+
introspection(true)
|
|
6
|
+
|
|
5
7
|
def self.field(*args, **kwargs, &block)
|
|
6
8
|
kwargs[:introspection] = true
|
|
7
9
|
super(*args, **kwargs, &block)
|
|
8
10
|
end
|
|
9
|
-
|
|
10
|
-
def self.inherited(child_class)
|
|
11
|
-
child_class.introspection(true)
|
|
12
|
-
super
|
|
13
|
-
end
|
|
14
11
|
end
|
|
15
12
|
end
|
|
16
13
|
end
|
|
@@ -6,8 +6,8 @@ module GraphQL
|
|
|
6
6
|
description "A Directive can be adjacent to many parts of the GraphQL language, "\
|
|
7
7
|
"a __DirectiveLocation describes one such possible adjacencies."
|
|
8
8
|
|
|
9
|
-
GraphQL::Directive::LOCATIONS.each do |location|
|
|
10
|
-
value(location.to_s, GraphQL::Directive::LOCATION_DESCRIPTIONS[location], value: location)
|
|
9
|
+
GraphQL::Schema::Directive::LOCATIONS.each do |location|
|
|
10
|
+
value(location.to_s, GraphQL::Schema::Directive::LOCATION_DESCRIPTIONS[location], value: location)
|
|
11
11
|
end
|
|
12
12
|
introspection true
|
|
13
13
|
end
|
|
@@ -9,16 +9,22 @@ module GraphQL
|
|
|
9
9
|
"in ways field arguments will not suffice, such as conditionally including or "\
|
|
10
10
|
"skipping a field. Directives provide this by describing additional information "\
|
|
11
11
|
"to the executor."
|
|
12
|
-
field :name, String, null: false
|
|
13
|
-
field :description, String
|
|
14
|
-
field :locations, [GraphQL::Schema::LateBoundType.new("__DirectiveLocation")], null: false
|
|
15
|
-
field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false
|
|
12
|
+
field :name, String, null: false, method: :graphql_name
|
|
13
|
+
field :description, String
|
|
14
|
+
field :locations, [GraphQL::Schema::LateBoundType.new("__DirectiveLocation")], null: false, scope: false
|
|
15
|
+
field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false, scope: false do
|
|
16
|
+
argument :include_deprecated, Boolean, required: false, default_value: false
|
|
17
|
+
end
|
|
16
18
|
field :on_operation, Boolean, null: false, deprecation_reason: "Use `locations`.", method: :on_operation?
|
|
17
19
|
field :on_fragment, Boolean, null: false, deprecation_reason: "Use `locations`.", method: :on_fragment?
|
|
18
20
|
field :on_field, Boolean, null: false, deprecation_reason: "Use `locations`.", method: :on_field?
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
field :is_repeatable, Boolean, method: :repeatable?
|
|
23
|
+
|
|
24
|
+
def args(include_deprecated:)
|
|
25
|
+
args = @context.warden.arguments(@object)
|
|
26
|
+
args = args.reject(&:deprecation_reason) unless include_deprecated
|
|
27
|
+
args
|
|
22
28
|
end
|
|
23
29
|
end
|
|
24
30
|
end
|
|
@@ -3,30 +3,30 @@ module GraphQL
|
|
|
3
3
|
module Introspection
|
|
4
4
|
class EntryPoints < Introspection::BaseObject
|
|
5
5
|
field :__schema, GraphQL::Schema::LateBoundType.new("__Schema"), "This GraphQL schema", null: false
|
|
6
|
-
field :__type, GraphQL::Schema::LateBoundType.new("__Type"), "A type in the GraphQL system"
|
|
7
|
-
argument :name, String
|
|
6
|
+
field :__type, GraphQL::Schema::LateBoundType.new("__Type"), "A type in the GraphQL system" do
|
|
7
|
+
argument :name, String
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def __schema
|
|
11
11
|
# Apply wrapping manually since this field isn't wrapped by instrumentation
|
|
12
12
|
schema = @context.query.schema
|
|
13
|
-
schema_type = schema.introspection_system.
|
|
14
|
-
schema_type.
|
|
13
|
+
schema_type = schema.introspection_system.types["__Schema"]
|
|
14
|
+
schema_type.type_class.authorized_new(schema, @context)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def __type(name:)
|
|
18
18
|
return unless context.warden.reachable_type?(name)
|
|
19
|
-
|
|
20
19
|
type = context.warden.get_type(name)
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
|
|
21
|
+
if type && context.interpreter? && !type.is_a?(Module)
|
|
22
|
+
type = type.type_class || raise("Invariant: interpreter requires class-based type for #{name}")
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
# The interpreter provides this wrapping, other execution doesnt, so support both.
|
|
26
26
|
if type && !context.interpreter?
|
|
27
27
|
# Apply wrapping manually since this field isn't wrapped by instrumentation
|
|
28
|
-
type_type = context.schema.introspection_system.
|
|
29
|
-
type = type_type.
|
|
28
|
+
type_type = context.schema.introspection_system.types["__Type"]
|
|
29
|
+
type = type_type.type_class.authorized_new(type, context)
|
|
30
30
|
end
|
|
31
31
|
type
|
|
32
32
|
end
|
|
@@ -7,9 +7,9 @@ module GraphQL
|
|
|
7
7
|
"placeholder for a string or numeric value. However an Enum value is returned in "\
|
|
8
8
|
"a JSON response as a string."
|
|
9
9
|
field :name, String, null: false
|
|
10
|
-
field :description, String
|
|
10
|
+
field :description, String
|
|
11
11
|
field :is_deprecated, Boolean, null: false
|
|
12
|
-
field :deprecation_reason, String
|
|
12
|
+
field :deprecation_reason, String
|
|
13
13
|
|
|
14
14
|
def name
|
|
15
15
|
object.graphql_name
|
|
@@ -6,18 +6,22 @@ module GraphQL
|
|
|
6
6
|
description "Object and Interface types are described by a list of Fields, each of which has "\
|
|
7
7
|
"a name, potentially a list of arguments, and a return type."
|
|
8
8
|
field :name, String, null: false
|
|
9
|
-
field :description, String
|
|
10
|
-
field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false
|
|
9
|
+
field :description, String
|
|
10
|
+
field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false, scope: false do
|
|
11
|
+
argument :include_deprecated, Boolean, required: false, default_value: false
|
|
12
|
+
end
|
|
11
13
|
field :type, GraphQL::Schema::LateBoundType.new("__Type"), null: false
|
|
12
14
|
field :is_deprecated, Boolean, null: false
|
|
13
|
-
field :deprecation_reason, String
|
|
15
|
+
field :deprecation_reason, String
|
|
14
16
|
|
|
15
17
|
def is_deprecated
|
|
16
18
|
!!@object.deprecation_reason
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
def args
|
|
20
|
-
@context.warden.arguments(@object)
|
|
21
|
+
def args(include_deprecated:)
|
|
22
|
+
args = @context.warden.arguments(@object)
|
|
23
|
+
args = args.reject(&:deprecation_reason) unless include_deprecated
|
|
24
|
+
args
|
|
21
25
|
end
|
|
22
26
|
end
|
|
23
27
|
end
|
|
@@ -7,9 +7,15 @@ module GraphQL
|
|
|
7
7
|
"InputObject are represented as Input Values which describe their type and "\
|
|
8
8
|
"optionally a default value."
|
|
9
9
|
field :name, String, null: false
|
|
10
|
-
field :description, String
|
|
10
|
+
field :description, String
|
|
11
11
|
field :type, GraphQL::Schema::LateBoundType.new("__Type"), null: false
|
|
12
|
-
field :default_value, String, "A GraphQL-formatted string representing the default value for this input value."
|
|
12
|
+
field :default_value, String, "A GraphQL-formatted string representing the default value for this input value."
|
|
13
|
+
field :is_deprecated, Boolean, null: false
|
|
14
|
+
field :deprecation_reason, String
|
|
15
|
+
|
|
16
|
+
def is_deprecated
|
|
17
|
+
!!@object.deprecation_reason
|
|
18
|
+
end
|
|
13
19
|
|
|
14
20
|
def default_value
|
|
15
21
|
if @object.default_value?
|
|
@@ -17,21 +23,45 @@ module GraphQL
|
|
|
17
23
|
if value.nil?
|
|
18
24
|
'null'
|
|
19
25
|
else
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
coerced_default_value
|
|
26
|
-
end
|
|
27
|
-
else
|
|
28
|
-
GraphQL::Language.serialize(coerced_default_value)
|
|
26
|
+
if (@object.type.kind.list? || (@object.type.kind.non_null? && @object.type.of_type.kind.list?)) && !value.respond_to?(:map)
|
|
27
|
+
# This is a bit odd -- we expect the default value to be an application-style value, so we use coerce result below.
|
|
28
|
+
# But coerce_result doesn't wrap single-item lists, which are valid inputs to list types.
|
|
29
|
+
# So, apply that wrapper here if needed.
|
|
30
|
+
value = [value]
|
|
29
31
|
end
|
|
32
|
+
coerced_default_value = @object.type.coerce_result(value, @context)
|
|
33
|
+
serialize_default_value(coerced_default_value, @object.type)
|
|
30
34
|
end
|
|
31
35
|
else
|
|
32
36
|
nil
|
|
33
37
|
end
|
|
34
38
|
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
# Recursively serialize, taking care not to add quotes to enum values
|
|
44
|
+
def serialize_default_value(value, type)
|
|
45
|
+
if value.nil?
|
|
46
|
+
'null'
|
|
47
|
+
elsif type.kind.list?
|
|
48
|
+
inner_type = type.of_type
|
|
49
|
+
"[" + value.map { |v| serialize_default_value(v, inner_type) }.join(", ") + "]"
|
|
50
|
+
elsif type.kind.non_null?
|
|
51
|
+
serialize_default_value(value, type.of_type)
|
|
52
|
+
elsif type.kind.enum?
|
|
53
|
+
value
|
|
54
|
+
elsif type.kind.input_object?
|
|
55
|
+
"{" +
|
|
56
|
+
value.map do |k, v|
|
|
57
|
+
arg_defn = type.get_argument(k, context)
|
|
58
|
+
"#{k}: #{serialize_default_value(v, arg_defn.type)}"
|
|
59
|
+
end.join(", ") +
|
|
60
|
+
"}"
|
|
61
|
+
else
|
|
62
|
+
GraphQL::Language.serialize(value)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
35
65
|
end
|
|
36
66
|
end
|
|
37
67
|
end
|
|
@@ -1,93 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
mutationType { name }
|
|
9
|
-
subscriptionType { name }
|
|
10
|
-
types {
|
|
11
|
-
...FullType
|
|
12
|
-
}
|
|
13
|
-
directives {
|
|
14
|
-
name
|
|
15
|
-
description
|
|
16
|
-
locations
|
|
17
|
-
args {
|
|
18
|
-
...InputValue
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
fragment FullType on __Type {
|
|
24
|
-
kind
|
|
25
|
-
name
|
|
26
|
-
description
|
|
27
|
-
fields(includeDeprecated: true) {
|
|
28
|
-
name
|
|
29
|
-
description
|
|
30
|
-
args {
|
|
31
|
-
...InputValue
|
|
32
|
-
}
|
|
33
|
-
type {
|
|
34
|
-
...TypeRef
|
|
35
|
-
}
|
|
36
|
-
isDeprecated
|
|
37
|
-
deprecationReason
|
|
38
|
-
}
|
|
39
|
-
inputFields {
|
|
40
|
-
...InputValue
|
|
41
|
-
}
|
|
42
|
-
interfaces {
|
|
43
|
-
...TypeRef
|
|
44
|
-
}
|
|
45
|
-
enumValues(includeDeprecated: true) {
|
|
46
|
-
name
|
|
47
|
-
description
|
|
48
|
-
isDeprecated
|
|
49
|
-
deprecationReason
|
|
50
|
-
}
|
|
51
|
-
possibleTypes {
|
|
52
|
-
...TypeRef
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
fragment InputValue on __InputValue {
|
|
56
|
-
name
|
|
57
|
-
description
|
|
58
|
-
type { ...TypeRef }
|
|
59
|
-
defaultValue
|
|
60
|
-
}
|
|
61
|
-
fragment TypeRef on __Type {
|
|
62
|
-
kind
|
|
63
|
-
name
|
|
64
|
-
ofType {
|
|
65
|
-
kind
|
|
66
|
-
name
|
|
67
|
-
ofType {
|
|
68
|
-
kind
|
|
69
|
-
name
|
|
70
|
-
ofType {
|
|
71
|
-
kind
|
|
72
|
-
name
|
|
73
|
-
ofType {
|
|
74
|
-
kind
|
|
75
|
-
name
|
|
76
|
-
ofType {
|
|
77
|
-
kind
|
|
78
|
-
name
|
|
79
|
-
ofType {
|
|
80
|
-
kind
|
|
81
|
-
name
|
|
82
|
-
ofType {
|
|
83
|
-
kind
|
|
84
|
-
name
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
"
|
|
2
|
+
|
|
3
|
+
# This query is used by graphql-client so don't add the includeDeprecated
|
|
4
|
+
# argument for inputFields since the server may not support it. Two stage
|
|
5
|
+
# introspection queries will be required to handle this in clients.
|
|
6
|
+
GraphQL::Introspection::INTROSPECTION_QUERY = GraphQL::Introspection.query
|
|
7
|
+
|
|
@@ -8,19 +8,19 @@ module GraphQL
|
|
|
8
8
|
"available types and directives on the server, as well as the entry points for "\
|
|
9
9
|
"query, mutation, and subscription operations."
|
|
10
10
|
|
|
11
|
-
field :types, [GraphQL::Schema::LateBoundType.new("__Type")], "A list of all types supported by this server.", null: false
|
|
12
|
-
field :
|
|
13
|
-
field :
|
|
14
|
-
field :
|
|
15
|
-
field :directives, [GraphQL::Schema::LateBoundType.new("__Directive")], "A list of all directives supported by this server.", null: false
|
|
11
|
+
field :types, [GraphQL::Schema::LateBoundType.new("__Type")], "A list of all types supported by this server.", null: false, scope: false
|
|
12
|
+
field :query_type, GraphQL::Schema::LateBoundType.new("__Type"), "The type that query operations will be rooted at.", null: false
|
|
13
|
+
field :mutation_type, GraphQL::Schema::LateBoundType.new("__Type"), "If this server supports mutation, the type that mutation operations will be rooted at."
|
|
14
|
+
field :subscription_type, GraphQL::Schema::LateBoundType.new("__Type"), "If this server support subscription, the type that subscription operations will be rooted at."
|
|
15
|
+
field :directives, [GraphQL::Schema::LateBoundType.new("__Directive")], "A list of all directives supported by this server.", null: false, scope: false
|
|
16
|
+
field :description, String, resolver_method: :schema_description
|
|
17
|
+
|
|
18
|
+
def schema_description
|
|
19
|
+
context.schema.description
|
|
20
|
+
end
|
|
16
21
|
|
|
17
22
|
def types
|
|
18
|
-
|
|
19
|
-
if context.interpreter?
|
|
20
|
-
types.map { |t| t.metadata[:type_class] || raise("Invariant: can't introspect non-class-based type: #{t}") }
|
|
21
|
-
else
|
|
22
|
-
types
|
|
23
|
-
end
|
|
23
|
+
@context.warden.reachable_types.sort_by(&:graphql_name)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def query_type
|
|
@@ -36,7 +36,7 @@ module GraphQL
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def directives
|
|
39
|
-
context.
|
|
39
|
+
@context.warden.directives
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
private
|