graphql 2.6.14 → 2.6.15
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/templates/graphql_controller.erb +7 -1
- data/lib/graphql/analysis/max_query_complexity.rb +2 -1
- data/lib/graphql/analysis/max_query_depth.rb +2 -1
- data/lib/graphql/analysis/query_complexity.rb +2 -1
- data/lib/graphql/analysis/query_depth.rb +1 -1
- data/lib/graphql/analysis/visitor.rb +14 -2
- data/lib/graphql/analysis.rb +4 -5
- data/lib/graphql/analysis_error.rb +1 -1
- data/lib/graphql/coercion_error.rb +1 -1
- data/lib/graphql/current.rb +5 -1
- data/lib/graphql/dashboard.rb +1 -1
- data/lib/graphql/date_encoding_error.rb +3 -1
- data/lib/graphql/duration_encoding_error.rb +3 -1
- data/lib/graphql/execution/directive_checks.rb +2 -1
- data/lib/graphql/execution/errors.rb +18 -7
- data/lib/graphql/execution/field_resolve_step.rb +3 -3
- data/lib/graphql/execution/input_values.rb +160 -120
- data/lib/graphql/execution/interpreter/runtime.rb +9 -5
- data/lib/graphql/execution/lookahead.rb +19 -8
- data/lib/graphql/execution/next.rb +1 -0
- data/lib/graphql/execution/runner.rb +19 -12
- data/lib/graphql/execution/selections_step.rb +1 -1
- data/lib/graphql/execution/variable_values.rb +248 -0
- data/lib/graphql/float_decoding_error.rb +3 -1
- data/lib/graphql/integer_decoding_error.rb +3 -1
- data/lib/graphql/introspection/base_object.rb +1 -1
- data/lib/graphql/introspection/directive_location_enum.rb +1 -1
- data/lib/graphql/introspection/directive_type.rb +3 -1
- data/lib/graphql/introspection/dynamic_fields.rb +3 -1
- data/lib/graphql/introspection/enum_value_type.rb +3 -1
- data/lib/graphql/introspection/field_type.rb +5 -1
- data/lib/graphql/introspection/type_kind_enum.rb +1 -1
- data/lib/graphql/introspection.rb +2 -1
- data/lib/graphql/language/comment.rb +2 -1
- data/lib/graphql/language/generation.rb +2 -1
- data/lib/graphql/language/lexer.rb +29 -21
- data/lib/graphql/language/parser.rb +10 -7
- data/lib/graphql/language.rb +1 -1
- data/lib/graphql/name_validator.rb +2 -1
- data/lib/graphql/pagination.rb +1 -1
- data/lib/graphql/query/fingerprint.rb +2 -1
- data/lib/graphql/query/partial.rb +4 -0
- data/lib/graphql/query.rb +8 -12
- data/lib/graphql/railtie.rb +1 -1
- data/lib/graphql/relay.rb +1 -1
- data/lib/graphql/rubocop.rb +1 -1
- data/lib/graphql/runtime_error.rb +1 -1
- data/lib/graphql/runtime_type_error.rb +1 -1
- data/lib/graphql/schema/always_visible.rb +3 -1
- data/lib/graphql/schema/base_64_encoder.rb +3 -1
- data/lib/graphql/schema/built_in_types.rb +2 -2
- data/lib/graphql/schema/directive/deprecated.rb +1 -1
- data/lib/graphql/schema/directive/include.rb +2 -1
- data/lib/graphql/schema/directive/skip.rb +2 -1
- data/lib/graphql/schema/directive/specified_by.rb +1 -1
- data/lib/graphql/schema/field/scope_extension.rb +2 -1
- data/lib/graphql/schema/field.rb +3 -0
- data/lib/graphql/schema/find_inherited_value.rb +5 -1
- data/lib/graphql/schema/member/graphql_type_names.rb +1 -1
- data/lib/graphql/schema/member/has_directives.rb +20 -22
- data/lib/graphql/schema/member/has_path.rb +2 -1
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +2 -1
- data/lib/graphql/schema/member.rb +3 -2
- data/lib/graphql/schema/mutation.rb +6 -1
- data/lib/graphql/schema/object.rb +1 -1
- data/lib/graphql/schema/resolver.rb +2 -2
- data/lib/graphql/schema/type_expression.rb +3 -1
- data/lib/graphql/schema/validator/all_validator.rb +6 -3
- data/lib/graphql/static_validation/all_rules.rb +1 -1
- data/lib/graphql/static_validation/base_visitor.rb +125 -53
- data/lib/graphql/static_validation/definition_dependencies.rb +14 -2
- data/lib/graphql/static_validation/interpreter_visitor.rb +1 -1
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +4 -1
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +2 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +8 -4
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +2 -1
- data/lib/graphql/static_validation/rules/fragments_are_named.rb +2 -1
- data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +4 -1
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +6 -3
- data/lib/graphql/static_validation/rules/fragments_are_used.rb +2 -1
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +3 -1
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +3 -2
- data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +4 -1
- data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +4 -1
- data/lib/graphql/static_validation/rules/not_single_subscription_error.rb +4 -1
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +9 -2
- data/lib/graphql/static_validation/rules/query_root_exists.rb +3 -2
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +4 -1
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +10 -4
- data/lib/graphql/static_validation/rules/subscription_root_exists_and_single_subscription_selection.rb +8 -6
- data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +4 -1
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +5 -4
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +2 -1
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +2 -1
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +1 -1
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
- data/lib/graphql/static_validation/validation_context.rb +49 -14
- data/lib/graphql/static_validation/validation_timeout_error.rb +4 -1
- data/lib/graphql/static_validation.rb +1 -2
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +14 -13
- data/lib/graphql/testing.rb +1 -1
- data/lib/graphql/tracing/legacy_trace.rb +1 -1
- data/lib/graphql/tracing/null_trace.rb +1 -1
- data/lib/graphql/types/big_int.rb +4 -1
- data/lib/graphql/types/boolean.rb +3 -1
- data/lib/graphql/types/id.rb +3 -1
- data/lib/graphql/types/iso_8601_date.rb +1 -0
- data/lib/graphql/types/iso_8601_date_time.rb +6 -2
- data/lib/graphql/types/iso_8601_duration.rb +3 -0
- data/lib/graphql/types/relay/base_connection.rb +1 -1
- data/lib/graphql/types/relay/base_edge.rb +1 -1
- data/lib/graphql/types/relay/node.rb +1 -1
- data/lib/graphql/types/relay/page_info.rb +1 -1
- data/lib/graphql/types/relay/page_info_behaviors.rb +4 -1
- data/lib/graphql/types/relay.rb +1 -1
- data/lib/graphql/types/string.rb +1 -0
- data/lib/graphql/types.rb +1 -1
- data/lib/graphql/version.rb +2 -2
- metadata +3 -4
- data/lib/graphql/query/variables.rb +0 -99
- data/lib/graphql/static_validation/literal_validator.rb +0 -157
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8207cb9fb1f93b3364a2866d4ad0113b9fb6711fed18173ab1b63a73c3b7004d
|
|
4
|
+
data.tar.gz: 170e3f0d0bb725d6d1bc6d21c2d086d3023d169544ea17bfc5d6765df57be66e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb6cdc6648667c5547960a18ffd070cb8c6cb98360adbd47316b792f4c16e594b9a074ff62028c44e3f041d9e7f28860b7f2fd3e4bc42db73d9f43ce0e81ae53
|
|
7
|
+
data.tar.gz: cb4b25050266be8b405105144a5b52ee82602b6dd8e99d1f9c32d8d29443e96b19a8af283584c3d5e69ae85f6747348421bdc21693673ed2678d896c5375f6ea
|
|
@@ -48,7 +48,13 @@ class GraphqlController < ApplicationController
|
|
|
48
48
|
logger.error e.message
|
|
49
49
|
logger.error e.backtrace.join("\n")
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
error_json = { errors: [{ message: e.message, backtrace: e.backtrace }], data: {} }
|
|
52
|
+
if response.committed?
|
|
53
|
+
# A streaming response (eg, with `@defer`) already started, so `render` would fail
|
|
54
|
+
response.stream.write(error_json.to_json)
|
|
55
|
+
else
|
|
56
|
+
render json: error_json, status: 500
|
|
57
|
+
end
|
|
52
58
|
end
|
|
53
59
|
end
|
|
54
60
|
<% end -%>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
module GraphQL
|
|
4
4
|
module Analysis
|
|
5
5
|
# Used under the hood to implement complexity validation,
|
|
6
6
|
# See [Schema.max_complexity](rdoc-ref:GraphQL::Schema.max_complexity) and `Query#max_complexity`.
|
|
7
7
|
class MaxQueryComplexity < QueryComplexity
|
|
8
|
+
#: -> GraphQL::AnalysisError?
|
|
8
9
|
def result
|
|
9
10
|
return if subject.max_complexity.nil?
|
|
10
11
|
|
|
@@ -308,7 +308,8 @@ module GraphQL
|
|
|
308
308
|
field_complexity(composite_scopes.last, max_complexity: field_cost, child_complexity: child_complexity)
|
|
309
309
|
end
|
|
310
310
|
|
|
311
|
-
|
|
311
|
+
# Like `merged_max_complexity`, a field never reduces the cost of its siblings.
|
|
312
|
+
field_cost > 0 ? total + field_cost : total
|
|
312
313
|
end
|
|
313
314
|
end
|
|
314
315
|
end
|
|
@@ -25,6 +25,8 @@ module GraphQL
|
|
|
25
25
|
@types = query.types
|
|
26
26
|
@response_path = []
|
|
27
27
|
@skip_stack = [false]
|
|
28
|
+
# For each selection set being visited, the fragments already inlined into it.
|
|
29
|
+
@inlined_fragments_stack = [{}]
|
|
28
30
|
@timeout_time = if timeout
|
|
29
31
|
Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second) + timeout
|
|
30
32
|
else
|
|
@@ -129,9 +131,11 @@ module GraphQL
|
|
|
129
131
|
object_type = @schema.root_type_for_operation(node.operation_type)
|
|
130
132
|
@object_types.push(object_type)
|
|
131
133
|
@path.push("#{node.operation_type}#{node.name ? " #{node.name}" : ""}")
|
|
134
|
+
@inlined_fragments_stack.push({})
|
|
132
135
|
call_on_enter_operation_definition(node, parent)
|
|
133
136
|
super
|
|
134
137
|
call_on_leave_operation_definition(node, parent)
|
|
138
|
+
@inlined_fragments_stack.pop
|
|
135
139
|
@object_types.pop
|
|
136
140
|
@path.pop
|
|
137
141
|
end
|
|
@@ -173,10 +177,12 @@ module GraphQL
|
|
|
173
177
|
@skipping = @skip_stack.last || skip?(node)
|
|
174
178
|
@skip_stack << @skipping
|
|
175
179
|
|
|
180
|
+
@inlined_fragments_stack.push({})
|
|
176
181
|
call_on_enter_field(node, parent)
|
|
177
182
|
super
|
|
178
183
|
@skipping = @skip_stack.pop
|
|
179
184
|
call_on_leave_field(node, parent)
|
|
185
|
+
@inlined_fragments_stack.pop
|
|
180
186
|
@response_path.pop
|
|
181
187
|
@field_definitions.pop
|
|
182
188
|
@object_types.pop
|
|
@@ -226,10 +232,16 @@ module GraphQL
|
|
|
226
232
|
@skip_stack << @skipping
|
|
227
233
|
|
|
228
234
|
call_on_enter_fragment_spread(node, parent)
|
|
229
|
-
|
|
235
|
+
# Spreading the same fragment again into this selection set adds no new selections, so don't visit it again.
|
|
236
|
+
inlined_fragments = @inlined_fragments_stack.last
|
|
237
|
+
inlined_key = [node.name, @object_types.last, @skipping]
|
|
238
|
+
if (inline_fragment = !inlined_fragments.key?(inlined_key))
|
|
239
|
+
inlined_fragments[inlined_key] = true
|
|
240
|
+
end
|
|
241
|
+
enter_fragment_spread_inline(node) if inline_fragment
|
|
230
242
|
super
|
|
231
243
|
@skipping = @skip_stack.pop
|
|
232
|
-
leave_fragment_spread_inline(node)
|
|
244
|
+
leave_fragment_spread_inline(node) if inline_fragment
|
|
233
245
|
call_on_leave_fragment_spread(node, parent)
|
|
234
246
|
@path.pop
|
|
235
247
|
end
|
data/lib/graphql/analysis.rb
CHANGED
|
@@ -97,17 +97,16 @@ module GraphQL
|
|
|
97
97
|
EmptyObjects::EMPTY_ARRAY
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
|
-
rescue
|
|
100
|
+
rescue GraphQL::ExecutionError => err
|
|
101
101
|
[err]
|
|
102
|
-
rescue GraphQL::UnauthorizedError
|
|
103
|
-
|
|
104
|
-
EmptyObjects::EMPTY_ARRAY
|
|
102
|
+
rescue GraphQL::UnauthorizedError => err
|
|
103
|
+
[GraphQL::AnalysisError.new(err.message)]
|
|
105
104
|
end
|
|
106
105
|
|
|
107
106
|
def analysis_errors(parent_errors, results)
|
|
108
107
|
if !results.empty?
|
|
109
108
|
results = results.flatten
|
|
110
|
-
results.select! { |r| r.is_a?(GraphQL::
|
|
109
|
+
results.select! { |r| r.is_a?(GraphQL::ExecutionError) }
|
|
111
110
|
end
|
|
112
111
|
|
|
113
112
|
if parent_errors.empty?
|
data/lib/graphql/current.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
|
|
4
4
|
module GraphQL
|
|
5
5
|
# This module exposes Fiber-level runtime information.
|
|
@@ -32,6 +32,7 @@ module GraphQL
|
|
|
32
32
|
#
|
|
33
33
|
# :call-seq:
|
|
34
34
|
# operation_name() -> String | nil
|
|
35
|
+
#: () -> String?
|
|
35
36
|
def self.operation_name
|
|
36
37
|
if (m = Fiber[:__graphql_current_multiplex])
|
|
37
38
|
m.context[:__graphql_current_operation_name] ||= begin
|
|
@@ -55,6 +56,7 @@ module GraphQL
|
|
|
55
56
|
#
|
|
56
57
|
# :call-seq:
|
|
57
58
|
# field() -> GraphQL::Field | nil
|
|
59
|
+
#: () -> GraphQL::Schema::Field?
|
|
58
60
|
def self.field
|
|
59
61
|
if (interpreter_info = Fiber[:__graphql_runtime_info])
|
|
60
62
|
interpreter_info.values&.first&.current_field
|
|
@@ -71,6 +73,7 @@ module GraphQL
|
|
|
71
73
|
#
|
|
72
74
|
# :call-seq:
|
|
73
75
|
# dataloader_source_class() -> Class | nil
|
|
76
|
+
#: () -> singleton(GraphQL::Dataloader::Source)?
|
|
74
77
|
def self.dataloader_source_class
|
|
75
78
|
Fiber[:__graphql_current_dataloader_source]&.class
|
|
76
79
|
end
|
|
@@ -81,6 +84,7 @@ module GraphQL
|
|
|
81
84
|
#
|
|
82
85
|
# :call-seq:
|
|
83
86
|
# dataloader_source() -> GraphQL::Dataloader::Source | nil
|
|
87
|
+
#: () -> GraphQL::Dataloader::Source?
|
|
84
88
|
def self.dataloader_source
|
|
85
89
|
Fiber[:__graphql_current_dataloader_source]
|
|
86
90
|
end
|
data/lib/graphql/dashboard.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
module GraphQL
|
|
4
4
|
# This error is raised when `Types::ISO8601Date` is asked to return a value
|
|
5
5
|
# that cannot be parsed to a Ruby Date.
|
|
@@ -7,8 +7,10 @@ module GraphQL
|
|
|
7
7
|
# See [GraphQL::Types::ISO8601Date](rdoc-ref:GraphQL::Types::ISO8601Date) which raises this error
|
|
8
8
|
class DateEncodingError < GraphQL::RuntimeTypeError
|
|
9
9
|
# The value which couldn't be encoded
|
|
10
|
+
#: untyped
|
|
10
11
|
attr_reader :date_value
|
|
11
12
|
|
|
13
|
+
#: (untyped value) -> void
|
|
12
14
|
def initialize(value)
|
|
13
15
|
@date_value = value
|
|
14
16
|
super("Date cannot be parsed: #{value}. \nDate must be able to be parsed as a Ruby Date object.")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
module GraphQL
|
|
4
4
|
# This error is raised when `Types::ISO8601Duration` is asked to return a value
|
|
5
5
|
# that cannot be parsed as an ISO8601-formatted duration by ActiveSupport::Duration.
|
|
@@ -7,8 +7,10 @@ module GraphQL
|
|
|
7
7
|
# See [GraphQL::Types::ISO8601Duration](rdoc-ref:GraphQL::Types::ISO8601Duration) which raises this error
|
|
8
8
|
class DurationEncodingError < GraphQL::RuntimeTypeError
|
|
9
9
|
# The value which couldn't be encoded
|
|
10
|
+
#: untyped
|
|
10
11
|
attr_reader :duration_value
|
|
11
12
|
|
|
13
|
+
#: (untyped value) -> void
|
|
12
14
|
def initialize(value)
|
|
13
15
|
@duration_value = value
|
|
14
16
|
super("Duration cannot be parsed: #{value}. \nDuration must be an ISO8601-formatted duration.")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
module GraphQL
|
|
4
4
|
module Execution
|
|
5
5
|
# Boolean checks for how an AST node's directives should
|
|
@@ -16,6 +16,7 @@ module GraphQL
|
|
|
16
16
|
#
|
|
17
17
|
# :call-seq:
|
|
18
18
|
# include?(directive_ast_nodes, query) -> bool
|
|
19
|
+
#: (Array[GraphQL::Language::Nodes::Directive] directive_ast_nodes, GraphQL::Query query) -> bool
|
|
19
20
|
def include?(directive_ast_nodes, query)
|
|
20
21
|
directive_ast_nodes.each do |directive_ast_node|
|
|
21
22
|
name = directive_ast_node.name
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# typed:
|
|
2
|
+
# typed: strict
|
|
3
3
|
|
|
4
4
|
module GraphQL
|
|
5
5
|
module Execution
|
|
6
6
|
class Errors
|
|
7
|
+
# One level of a schema's `rescue_from` index: the handler registered for `class` (if any),
|
|
8
|
+
# plus handlers for its subclasses, keyed by error class.
|
|
9
|
+
# (Sorbet doesn't support recursive type aliases, so the nested entries are `untyped`.)
|
|
10
|
+
#: type handler_entry = { class: singleton(Exception)?, handler: Proc?, subclass_handlers: Hash[singleton(Exception), untyped] }
|
|
11
|
+
|
|
7
12
|
# Register this handler, updating the
|
|
8
13
|
# internal handler index to maintain least-to-most specific.
|
|
9
14
|
#
|
|
@@ -19,9 +24,10 @@ module GraphQL
|
|
|
19
24
|
#
|
|
20
25
|
# :call-seq:
|
|
21
26
|
# register_rescue_from(Class[Exception] error_class, Hash error_handlers, Proc error_handler) -> void
|
|
27
|
+
#: (singleton(Exception) error_class, Hash[singleton(Exception), handler_entry] error_handlers, Proc error_handler) -> void
|
|
22
28
|
def self.register_rescue_from(error_class, error_handlers, error_handler)
|
|
23
|
-
subclasses_handlers = {}
|
|
24
|
-
this_level_subclasses = []
|
|
29
|
+
subclasses_handlers = {} #: Hash[singleton(Exception), handler_entry]
|
|
30
|
+
this_level_subclasses = [] #: Array[singleton(Exception)]
|
|
25
31
|
# During this traversal, do two things:
|
|
26
32
|
# - Identify any already-registered subclasses of this error class
|
|
27
33
|
# and gather them up to be inserted _under_ this class
|
|
@@ -46,7 +52,7 @@ module GraphQL
|
|
|
46
52
|
# See if any keys in this hash are superclasses of this new class:
|
|
47
53
|
next_index_point = error_handlers.find { |err_class, handler| error_class < err_class }
|
|
48
54
|
if next_index_point
|
|
49
|
-
error_handlers = next_index_point[1][:subclass_handlers]
|
|
55
|
+
error_handlers = next_index_point[1][:subclass_handlers] #: as Hash[singleton(Exception), handler_entry]
|
|
50
56
|
else
|
|
51
57
|
# this new handler doesn't belong to any sub-handlers,
|
|
52
58
|
# so insert it in the current set of `handlers`
|
|
@@ -55,7 +61,8 @@ module GraphQL
|
|
|
55
61
|
end
|
|
56
62
|
# Having found the point at which to insert this handler,
|
|
57
63
|
# register it and merge any subclass handlers back in at this point.
|
|
58
|
-
|
|
64
|
+
# `error_handlers` has a default proc, so this is never `nil`:
|
|
65
|
+
this_class_handlers = error_handlers[error_class] #: as !nil
|
|
59
66
|
this_class_handlers[:handler] = error_handler
|
|
60
67
|
this_class_handlers[:subclass_handlers].merge!(subclasses_handlers)
|
|
61
68
|
nil
|
|
@@ -67,9 +74,10 @@ module GraphQL
|
|
|
67
74
|
#
|
|
68
75
|
# :call-seq:
|
|
69
76
|
# find_handler_for(schema, error_class) -> Proc | nil
|
|
77
|
+
#: (singleton(GraphQL::Schema) schema, singleton(Exception) error_class) -> handler_entry?
|
|
70
78
|
def self.find_handler_for(schema, error_class)
|
|
71
79
|
handlers = schema.error_handlers[:subclass_handlers]
|
|
72
|
-
handler = nil #:
|
|
80
|
+
handler = nil #: handler_entry?
|
|
73
81
|
while (handlers) do
|
|
74
82
|
_err_class, next_handler = handlers.find { |err_class, handler| error_class <= err_class }
|
|
75
83
|
if next_handler
|
|
@@ -84,7 +92,10 @@ module GraphQL
|
|
|
84
92
|
|
|
85
93
|
# check for a handler from a parent class:
|
|
86
94
|
if schema.superclass.respond_to?(:error_handlers)
|
|
87
|
-
parent_handler = find_handler_for(
|
|
95
|
+
parent_handler = find_handler_for(
|
|
96
|
+
schema.superclass, #: as singleton(GraphQL::Schema)
|
|
97
|
+
error_class,
|
|
98
|
+
)
|
|
88
99
|
end
|
|
89
100
|
|
|
90
101
|
# If the inherited handler is more specific than the one defined here,
|
|
@@ -184,7 +184,7 @@ module GraphQL
|
|
|
184
184
|
field_name = @ast_node.name
|
|
185
185
|
@field_definition = query.types.field(@parent_type, field_name) || raise(GraphQL::Error, "No field definition found for #{@parent_type.to_type_signature}.#{ast_node.name} (at #{@ast_node.position})")
|
|
186
186
|
set_current_field
|
|
187
|
-
@arguments, errors =
|
|
187
|
+
@arguments, errors = query.input_values.argument_values(@field_definition, @ast_node.arguments, self) # rubocop:disable Development/ContextIsPassedCop
|
|
188
188
|
if errors
|
|
189
189
|
build_errors_result(errors, nil)
|
|
190
190
|
return
|
|
@@ -201,7 +201,7 @@ module GraphQL
|
|
|
201
201
|
# Used for compatibility in Schema::Subscription
|
|
202
202
|
def arguments_without_loads
|
|
203
203
|
if @arguments_without_loads.nil?
|
|
204
|
-
@arguments_without_loads, _errors = @
|
|
204
|
+
@arguments_without_loads, _errors = @selections_step.query.input_values.argument_values(@field_definition, ast_node.arguments, nil)
|
|
205
205
|
end
|
|
206
206
|
@arguments_without_loads
|
|
207
207
|
end
|
|
@@ -550,7 +550,7 @@ module GraphQL
|
|
|
550
550
|
if directives
|
|
551
551
|
directives.each do |dir_node|
|
|
552
552
|
if (dir_defn = @runner.runtime_directives[dir_node.name])
|
|
553
|
-
dir_args, errors =
|
|
553
|
+
dir_args, errors = query.input_values.argument_values(dir_defn, dir_node.arguments, self) # rubocop:disable Development/ContextIsPassedCop
|
|
554
554
|
if errors
|
|
555
555
|
@results.each { |r| r.delete(@key) }
|
|
556
556
|
errors.each { |e| e.ast_node = dir_node }
|