graphql 1.10.7 → 1.10.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/analysis/ast/query_complexity.rb +1 -1
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +2 -2
- data/lib/graphql/execution/interpreter.rb +2 -0
- data/lib/graphql/execution/interpreter/argument_value.rb +28 -0
- data/lib/graphql/execution/interpreter/arguments.rb +39 -0
- data/lib/graphql/execution/interpreter/arguments_cache.rb +3 -7
- data/lib/graphql/execution/interpreter/runtime.rb +20 -12
- data/lib/graphql/execution/lookahead.rb +3 -1
- data/lib/graphql/internal_representation/scope.rb +2 -2
- data/lib/graphql/internal_representation/visit.rb +2 -2
- data/lib/graphql/relay/base_connection.rb +0 -2
- data/lib/graphql/schema.rb +6 -8
- data/lib/graphql/schema/base_64_encoder.rb +2 -0
- data/lib/graphql/schema/field.rb +6 -1
- data/lib/graphql/schema/input_object.rb +9 -6
- data/lib/graphql/schema/member/has_arguments.rb +27 -13
- data/lib/graphql/schema/object.rb +2 -2
- data/lib/graphql/schema/resolver.rb +1 -1
- data/lib/graphql/tracing.rb +5 -4
- data/lib/graphql/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13caa4920df03f81232a23cf9fe5707ee3602a6c42bedace93870645f35d1248
|
4
|
+
data.tar.gz: 597cbe2fd51c36a0e0de158d51c70d1d057a2712d44a34c71872ef0586a9c3d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca5468c4b6632a4028f4bebf226c7a3aee5bb6786096b1b5a843b2ae476043160b1fe52111ae70d62c5a35cc66f9edd2d903128ebb2412c87054b9040f2a55aa
|
7
|
+
data.tar.gz: e9ad2d87cb3898d849266bb743251d922024541ee9d08090cb4f7898331fa15962697a87f386011b7450ca9af3c730c23ff74ca4d2191af6c319d3168add1bdd
|
@@ -54,7 +54,7 @@ module GraphQL
|
|
54
54
|
case defined_complexity
|
55
55
|
when Proc
|
56
56
|
arguments = @query.arguments_for(@node, @field_definition)
|
57
|
-
defined_complexity.call(@query.context, arguments, child_complexity)
|
57
|
+
defined_complexity.call(@query.context, arguments.keyword_arguments, child_complexity)
|
58
58
|
when Numeric
|
59
59
|
defined_complexity + child_complexity
|
60
60
|
else
|
@@ -1,4 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require "graphql/execution/interpreter/argument_value"
|
3
|
+
require "graphql/execution/interpreter/arguments"
|
2
4
|
require "graphql/execution/interpreter/arguments_cache"
|
3
5
|
require "graphql/execution/interpreter/execution_errors"
|
4
6
|
require "graphql/execution/interpreter/hash_response"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Execution
|
5
|
+
class Interpreter
|
6
|
+
# A container for metadata regarding arguments present in a GraphQL query.
|
7
|
+
# @see Interpreter::Arguments#argument_values for a hash of these objects.
|
8
|
+
class ArgumentValue
|
9
|
+
def initialize(definition:, value:, default_used:)
|
10
|
+
@definition = definition
|
11
|
+
@value = value
|
12
|
+
@default_used = default_used
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Object] The Ruby-ready value for this Argument
|
16
|
+
attr_reader :value
|
17
|
+
|
18
|
+
# @return [GraphQL::Schema::Argument] The definition instance for this argument
|
19
|
+
attr_reader :definition
|
20
|
+
|
21
|
+
# @return [Boolean] `true` if the schema-defined `default_value:` was applied in this case. (No client-provided value was present.)
|
22
|
+
def default_used?
|
23
|
+
@default_used
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Execution
|
5
|
+
class Interpreter
|
6
|
+
# A wrapper for argument hashes in GraphQL queries.
|
7
|
+
#
|
8
|
+
# @see GraphQL::Query#arguments_for to get access to these objects.
|
9
|
+
class Arguments
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
# The Ruby-style arguments hash, ready for a resolver.
|
13
|
+
# This hash is the one used at runtime.
|
14
|
+
#
|
15
|
+
# @return [Hash<Symbol, Object>]
|
16
|
+
attr_reader :keyword_arguments
|
17
|
+
|
18
|
+
def initialize(keyword_arguments:, argument_values:)
|
19
|
+
@keyword_arguments = keyword_arguments
|
20
|
+
@argument_values = argument_values
|
21
|
+
end
|
22
|
+
|
23
|
+
# Yields `ArgumentValue` instances which contain detailed metadata about each argument.
|
24
|
+
def each_value
|
25
|
+
argument_values.each { |arg_v| yield(arg_v) }
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Hash{Symbol => ArgumentValue}]
|
29
|
+
attr_reader :argument_values
|
30
|
+
|
31
|
+
def_delegators :@keyword_arguments, :key?, :[], :keys, :each, :values
|
32
|
+
|
33
|
+
def inspect
|
34
|
+
"#<#{self.class} @keyword_arguments=#{keyword_arguments.inspect}>"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -14,13 +14,9 @@ module GraphQL
|
|
14
14
|
# Then call into the schema to coerce those incoming values
|
15
15
|
args = arg_owner.coerce_arguments(parent_object, args_hash, query.context)
|
16
16
|
|
17
|
-
h3[parent_object] =
|
18
|
-
|
19
|
-
|
20
|
-
h3[parent_object] = resolved_args
|
21
|
-
}
|
22
|
-
else
|
23
|
-
args
|
17
|
+
h3[parent_object] = @query.schema.after_lazy(args) do |resolved_args|
|
18
|
+
# when this promise is resolved, update the cache with the resolved value
|
19
|
+
h3[parent_object] = resolved_args
|
24
20
|
end
|
25
21
|
end
|
26
22
|
end
|
@@ -174,7 +174,14 @@ module GraphQL
|
|
174
174
|
next
|
175
175
|
end
|
176
176
|
|
177
|
-
after_lazy(kwarg_arguments, owner: owner_type, field: field_defn, path: next_path, scoped_context: context.scoped_context, owner_object: object, arguments: kwarg_arguments) do |
|
177
|
+
after_lazy(kwarg_arguments, owner: owner_type, field: field_defn, path: next_path, scoped_context: context.scoped_context, owner_object: object, arguments: kwarg_arguments) do |resolved_arguments|
|
178
|
+
if resolved_arguments.is_a? GraphQL::ExecutionError
|
179
|
+
continue_value(next_path, resolved_arguments, field_defn, return_type.non_null?, ast_node)
|
180
|
+
next
|
181
|
+
end
|
182
|
+
|
183
|
+
kwarg_arguments = resolved_arguments.keyword_arguments
|
184
|
+
|
178
185
|
# It might turn out that making arguments for every field is slow.
|
179
186
|
# If we have to cache them, we'll need a more subtle approach here.
|
180
187
|
field_defn.extras.each do |extra|
|
@@ -194,6 +201,8 @@ module GraphQL
|
|
194
201
|
ast_nodes: field_ast_nodes,
|
195
202
|
field: field_defn,
|
196
203
|
)
|
204
|
+
when :argument_details
|
205
|
+
kwarg_arguments[:argument_details] = resolved_arguments
|
197
206
|
else
|
198
207
|
kwarg_arguments[extra] = field_defn.fetch_extra(extra, context)
|
199
208
|
end
|
@@ -369,11 +378,12 @@ module GraphQL
|
|
369
378
|
end
|
370
379
|
end
|
371
380
|
|
372
|
-
def resolve_with_directives(object, ast_node)
|
373
|
-
|
381
|
+
def resolve_with_directives(object, ast_node, &block)
|
382
|
+
return yield if ast_node.directives.empty?
|
383
|
+
run_directive(object, ast_node, 0, &block)
|
374
384
|
end
|
375
385
|
|
376
|
-
def run_directive(object, ast_node, idx)
|
386
|
+
def run_directive(object, ast_node, idx, &block)
|
377
387
|
dir_node = ast_node.directives[idx]
|
378
388
|
if !dir_node
|
379
389
|
yield
|
@@ -382,9 +392,9 @@ module GraphQL
|
|
382
392
|
if !dir_defn.is_a?(Class)
|
383
393
|
dir_defn = dir_defn.type_class || raise("Only class-based directives are supported (not `@#{dir_node.name}`)")
|
384
394
|
end
|
385
|
-
dir_args = arguments(nil, dir_defn, dir_node)
|
395
|
+
dir_args = arguments(nil, dir_defn, dir_node).keyword_arguments
|
386
396
|
dir_defn.resolve(object, dir_args, context) do
|
387
|
-
run_directive(object, ast_node, idx + 1)
|
397
|
+
run_directive(object, ast_node, idx + 1, &block)
|
388
398
|
end
|
389
399
|
end
|
390
400
|
end
|
@@ -393,7 +403,7 @@ module GraphQL
|
|
393
403
|
def directives_include?(node, graphql_object, parent_type)
|
394
404
|
node.directives.each do |dir_node|
|
395
405
|
dir_defn = schema.directives.fetch(dir_node.name).type_class || raise("Only class-based directives are supported (not #{dir_node.name.inspect})")
|
396
|
-
args = arguments(graphql_object, dir_defn, dir_node)
|
406
|
+
args = arguments(graphql_object, dir_defn, dir_node).keyword_arguments
|
397
407
|
if !dir_defn.include?(graphql_object, args, context)
|
398
408
|
return false
|
399
409
|
end
|
@@ -407,7 +417,7 @@ module GraphQL
|
|
407
417
|
# @param eager [Boolean] Set to `true` for mutation root fields only
|
408
418
|
# @param trace [Boolean] If `false`, don't wrap this with field tracing
|
409
419
|
# @return [GraphQL::Execution::Lazy, Object] If loading `object` will be deferred, it's a wrapper over it.
|
410
|
-
def after_lazy(lazy_obj, owner:, field:, path:, scoped_context:, owner_object:, arguments:, eager: false, trace: true)
|
420
|
+
def after_lazy(lazy_obj, owner:, field:, path:, scoped_context:, owner_object:, arguments:, eager: false, trace: true, &block)
|
411
421
|
@interpreter_context[:current_object] = owner_object
|
412
422
|
@interpreter_context[:current_arguments] = arguments
|
413
423
|
@interpreter_context[:current_path] = path
|
@@ -432,11 +442,9 @@ module GraphQL
|
|
432
442
|
end
|
433
443
|
end
|
434
444
|
rescue GraphQL::ExecutionError, GraphQL::UnauthorizedError => err
|
435
|
-
|
436
|
-
end
|
437
|
-
after_lazy(inner_obj, owner: owner, field: field, path: path, scoped_context: context.scoped_context, owner_object: owner_object, arguments: arguments, eager: eager) do |really_inner_obj|
|
438
|
-
yield(really_inner_obj)
|
445
|
+
err
|
439
446
|
end
|
447
|
+
after_lazy(inner_obj, owner: owner, field: field, path: path, scoped_context: context.scoped_context, owner_object: owner_object, arguments: arguments, eager: eager, trace: trace, &block)
|
440
448
|
end
|
441
449
|
|
442
450
|
if eager
|
@@ -55,7 +55,9 @@ module GraphQL
|
|
55
55
|
@arguments
|
56
56
|
else
|
57
57
|
@arguments = if @field
|
58
|
-
@query.arguments_for(@ast_nodes.first, @field)
|
58
|
+
@query.schema.after_lazy(@query.arguments_for(@ast_nodes.first, @field)) do |args|
|
59
|
+
args.is_a?(Execution::Interpreter::Arguments) ? args.keyword_arguments : args
|
60
|
+
end
|
59
61
|
else
|
60
62
|
nil
|
61
63
|
end
|
@@ -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
|
data/lib/graphql/schema.rb
CHANGED
@@ -101,14 +101,12 @@ module GraphQL
|
|
101
101
|
# - Right away, if `value` is not registered with `lazy_resolve`
|
102
102
|
# - After resolving `value`, if it's registered with `lazy_resolve` (eg, `Promise`)
|
103
103
|
# @api private
|
104
|
-
def after_lazy(value)
|
104
|
+
def after_lazy(value, &block)
|
105
105
|
if lazy?(value)
|
106
106
|
GraphQL::Execution::Lazy.new do
|
107
107
|
result = sync_lazy(value)
|
108
108
|
# The returned result might also be lazy, so check it, too
|
109
|
-
after_lazy(result)
|
110
|
-
yield(final_result) if block_given?
|
111
|
-
end
|
109
|
+
after_lazy(result, &block)
|
112
110
|
end
|
113
111
|
else
|
114
112
|
yield(value) if block_given?
|
@@ -146,10 +144,10 @@ module GraphQL
|
|
146
144
|
def after_any_lazies(maybe_lazies)
|
147
145
|
if maybe_lazies.any? { |l| lazy?(l) }
|
148
146
|
GraphQL::Execution::Lazy.all(maybe_lazies).then do |result|
|
149
|
-
yield
|
147
|
+
yield result
|
150
148
|
end
|
151
149
|
else
|
152
|
-
yield
|
150
|
+
yield maybe_lazies
|
153
151
|
end
|
154
152
|
end
|
155
153
|
end
|
@@ -872,8 +870,8 @@ module GraphQL
|
|
872
870
|
# Returns the JSON response of {Introspection::INTROSPECTION_QUERY}.
|
873
871
|
# @see {#as_json}
|
874
872
|
# @return [String]
|
875
|
-
def to_json(
|
876
|
-
JSON.pretty_generate(as_json(
|
873
|
+
def to_json(**args)
|
874
|
+
JSON.pretty_generate(as_json(**args))
|
877
875
|
end
|
878
876
|
|
879
877
|
# Return the Hash response of {Introspection::INTROSPECTION_QUERY}.
|
@@ -13,6 +13,8 @@ module GraphQL
|
|
13
13
|
def self.decode(encoded_text, nonce: false)
|
14
14
|
# urlsafe_decode64 is for forward compatibility
|
15
15
|
Base64Bp.urlsafe_decode64(encoded_text)
|
16
|
+
rescue ArgumentError
|
17
|
+
raise GraphQL::ExecutionError, "Invalid input: #{encoded_text.inspect}"
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/graphql/schema/field.rb
CHANGED
@@ -47,6 +47,11 @@ module GraphQL
|
|
47
47
|
@resolver_class
|
48
48
|
end
|
49
49
|
|
50
|
+
# @return [Boolean] Is this field a predefined introspection field?
|
51
|
+
def introspection?
|
52
|
+
@introspection
|
53
|
+
end
|
54
|
+
|
50
55
|
alias :mutation :resolver
|
51
56
|
|
52
57
|
# @return [Boolean] Apply tracing to this field? (Default: skip scalars, this is the override value)
|
@@ -663,7 +668,7 @@ module GraphQL
|
|
663
668
|
loaded_value = if loads && !arg_defn.from_resolver?
|
664
669
|
if arg_defn.type.list?
|
665
670
|
loaded_values = value.map { |val| load_application_object(arg_defn, loads, val, field_ctx.query.context) }
|
666
|
-
|
671
|
+
field_ctx.schema.after_any_lazies(loaded_values) { |result| result }
|
667
672
|
else
|
668
673
|
load_application_object(arg_defn, loads, value, field_ctx.query.context)
|
669
674
|
end
|
@@ -10,12 +10,13 @@ module GraphQL
|
|
10
10
|
|
11
11
|
include GraphQL::Dig
|
12
12
|
|
13
|
-
def initialize(
|
13
|
+
def initialize(arguments = nil, ruby_kwargs: nil, context:, defaults_used:)
|
14
14
|
@context = context
|
15
15
|
if ruby_kwargs
|
16
16
|
@ruby_style_hash = ruby_kwargs
|
17
|
+
@arguments = arguments
|
17
18
|
else
|
18
|
-
@arguments = self.class.arguments_class.new(
|
19
|
+
@arguments = self.class.arguments_class.new(arguments, context: context, defaults_used: defaults_used)
|
19
20
|
# Symbolized, underscored hash:
|
20
21
|
@ruby_style_hash = @arguments.to_kwargs
|
21
22
|
end
|
@@ -56,7 +57,7 @@ module GraphQL
|
|
56
57
|
# @return [GraphQL::Query::Context] The context for this query
|
57
58
|
attr_reader :context
|
58
59
|
|
59
|
-
# @return [GraphQL::Query::Arguments] The underlying arguments instance
|
60
|
+
# @return [GraphQL::Query::Arguments, GraphQL::Execution::Interpereter::Arguments] The underlying arguments instance
|
60
61
|
attr_reader :arguments
|
61
62
|
|
62
63
|
# Ruby-like hash behaviors, read-only
|
@@ -208,10 +209,12 @@ module GraphQL
|
|
208
209
|
return nil
|
209
210
|
end
|
210
211
|
|
211
|
-
|
212
|
+
arguments = coerce_arguments(nil, value, ctx)
|
212
213
|
|
213
|
-
|
214
|
-
|
214
|
+
ctx.schema.after_lazy(arguments) do |resolved_arguments|
|
215
|
+
input_obj_instance = self.new(resolved_arguments, ruby_kwargs: resolved_arguments.keyword_arguments, context: ctx, defaults_used: nil)
|
216
|
+
input_obj_instance.prepare
|
217
|
+
end
|
215
218
|
end
|
216
219
|
|
217
220
|
# It's funny to think of a _result_ of an input object.
|
@@ -63,10 +63,12 @@ module GraphQL
|
|
63
63
|
self.class.argument_class(new_arg_class)
|
64
64
|
end
|
65
65
|
|
66
|
+
# @api private
|
66
67
|
# @param values [Hash<String, Object>]
|
67
68
|
# @param context [GraphQL::Query::Context]
|
68
|
-
# @return Hash<Symbol, Object>
|
69
|
+
# @return [Hash<Symbol, Object>, Execution::Lazy<Hash>]
|
69
70
|
def coerce_arguments(parent_object, values, context)
|
71
|
+
argument_values = {}
|
70
72
|
kwarg_arguments = {}
|
71
73
|
# Cache this hash to avoid re-merging it
|
72
74
|
arg_defns = self.arguments
|
@@ -75,6 +77,7 @@ module GraphQL
|
|
75
77
|
arg_lazies = arg_defns.map do |arg_name, arg_defn|
|
76
78
|
arg_key = arg_defn.keyword
|
77
79
|
has_value = false
|
80
|
+
default_used = false
|
78
81
|
if values.key?(arg_name)
|
79
82
|
has_value = true
|
80
83
|
value = values[arg_name]
|
@@ -84,6 +87,7 @@ module GraphQL
|
|
84
87
|
elsif arg_defn.default_value?
|
85
88
|
has_value = true
|
86
89
|
value = arg_defn.default_value
|
90
|
+
default_used = true
|
87
91
|
end
|
88
92
|
|
89
93
|
if has_value
|
@@ -91,33 +95,43 @@ module GraphQL
|
|
91
95
|
loaded_value = nil
|
92
96
|
if loads && !arg_defn.from_resolver?
|
93
97
|
loaded_value = if arg_defn.type.list?
|
94
|
-
value.map { |val| load_application_object(arg_defn, loads, val, context) }
|
98
|
+
loaded_values = value.map { |val| load_application_object(arg_defn, loads, val, context) }
|
99
|
+
context.schema.after_any_lazies(loaded_values) { |result| result }
|
95
100
|
else
|
96
101
|
load_application_object(arg_defn, loads, value, context)
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
arg_defn.type.coerce_input(value, context)
|
108
|
-
end
|
105
|
+
coerced_value = if loaded_value
|
106
|
+
loaded_value
|
107
|
+
else
|
108
|
+
context.schema.error_handler.with_error_handling(context) do
|
109
|
+
arg_defn.type.coerce_input(value, context)
|
110
|
+
end
|
111
|
+
end
|
109
112
|
|
113
|
+
context.schema.after_lazy(coerced_value) do |coerced_value|
|
114
|
+
prepared_value = context.schema.error_handler.with_error_handling(context) do
|
110
115
|
arg_defn.prepare_value(parent_object, coerced_value, context: context)
|
111
116
|
end
|
112
117
|
|
113
|
-
kwarg_arguments[
|
118
|
+
kwarg_arguments[arg_key] = prepared_value
|
119
|
+
# TODO code smell to access such a deeply-nested constant in a distant module
|
120
|
+
argument_values[arg_key] = GraphQL::Execution::Interpreter::ArgumentValue.new(
|
121
|
+
value: prepared_value,
|
122
|
+
definition: arg_defn,
|
123
|
+
default_used: default_used,
|
124
|
+
)
|
114
125
|
end
|
115
126
|
end
|
116
127
|
end
|
117
128
|
|
118
129
|
maybe_lazies.concat(arg_lazies)
|
119
130
|
context.schema.after_any_lazies(maybe_lazies) do
|
120
|
-
|
131
|
+
GraphQL::Execution::Interpreter::Arguments.new(
|
132
|
+
keyword_arguments: kwarg_arguments,
|
133
|
+
argument_values: argument_values,
|
134
|
+
)
|
121
135
|
end
|
122
136
|
end
|
123
137
|
|
@@ -79,14 +79,14 @@ module GraphQL
|
|
79
79
|
raise "#{int} cannot be implemented since it's not a GraphQL Interface. Use `include` for plain Ruby modules."
|
80
80
|
end
|
81
81
|
|
82
|
-
new_memberships << int.type_membership_class.new(int, self, options)
|
82
|
+
new_memberships << int.type_membership_class.new(int, self, **options)
|
83
83
|
|
84
84
|
# Include the methods here,
|
85
85
|
# `.fields` will use the inheritance chain
|
86
86
|
# to find inherited fields
|
87
87
|
include(int)
|
88
88
|
elsif int.is_a?(GraphQL::InterfaceType)
|
89
|
-
new_memberships << int.type_membership_class.new(int, self, options)
|
89
|
+
new_memberships << int.type_membership_class.new(int, self, **options)
|
90
90
|
elsif int.is_a?(String) || int.is_a?(GraphQL::Schema::LateBoundType)
|
91
91
|
if options.any?
|
92
92
|
raise ArgumentError, "`implements(...)` doesn't support options with late-loaded types yet. Remove #{options} and open an issue to request this feature."
|
@@ -220,7 +220,7 @@ module GraphQL
|
|
220
220
|
# or use it as a configuration method to assign a return type
|
221
221
|
# instead of generating one.
|
222
222
|
# TODO unify with {#null}
|
223
|
-
# @param new_type [Class, nil] If a type definition class is provided, it will be used as the return type of the field
|
223
|
+
# @param new_type [Class, Array<Class>, nil] If a type definition class is provided, it will be used as the return type of the field
|
224
224
|
# @param null [true, false] Whether or not the field may return `nil`
|
225
225
|
# @return [Class] The type which this field returns.
|
226
226
|
def type(new_type = nil, null: nil)
|
data/lib/graphql/tracing.rb
CHANGED
@@ -63,8 +63,9 @@ module GraphQL
|
|
63
63
|
# @param key [String] The name of the event in GraphQL internals
|
64
64
|
# @param metadata [Hash] Event-related metadata (can be anything)
|
65
65
|
# @return [Object] Must return the value of the block
|
66
|
-
def trace(key, metadata)
|
67
|
-
|
66
|
+
def trace(key, metadata, &block)
|
67
|
+
return yield if @tracers.empty?
|
68
|
+
call_tracers(0, key, metadata, &block)
|
68
69
|
end
|
69
70
|
|
70
71
|
private
|
@@ -76,11 +77,11 @@ module GraphQL
|
|
76
77
|
# @param key [String] The current event name
|
77
78
|
# @param metadata [Object] The current event object
|
78
79
|
# @return Whatever the block returns
|
79
|
-
def call_tracers(idx, key, metadata)
|
80
|
+
def call_tracers(idx, key, metadata, &block)
|
80
81
|
if idx == @tracers.length
|
81
82
|
yield
|
82
83
|
else
|
83
|
-
@tracers[idx].trace(key, metadata) { call_tracers(idx + 1, key, metadata)
|
84
|
+
@tracers[idx].trace(key, metadata) { call_tracers(idx + 1, key, metadata, &block) }
|
84
85
|
end
|
85
86
|
end
|
86
87
|
end
|
data/lib/graphql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -422,6 +422,8 @@ files:
|
|
422
422
|
- lib/graphql/execution/flatten.rb
|
423
423
|
- lib/graphql/execution/instrumentation.rb
|
424
424
|
- lib/graphql/execution/interpreter.rb
|
425
|
+
- lib/graphql/execution/interpreter/argument_value.rb
|
426
|
+
- lib/graphql/execution/interpreter/arguments.rb
|
425
427
|
- lib/graphql/execution/interpreter/arguments_cache.rb
|
426
428
|
- lib/graphql/execution/interpreter/execution_errors.rb
|
427
429
|
- lib/graphql/execution/interpreter/handles_raw_value.rb
|
@@ -746,7 +748,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
746
748
|
- !ruby/object:Gem::Version
|
747
749
|
version: '0'
|
748
750
|
requirements: []
|
749
|
-
rubygems_version: 3.
|
751
|
+
rubygems_version: 3.1.2
|
750
752
|
signing_key:
|
751
753
|
specification_version: 4
|
752
754
|
summary: A GraphQL language and runtime for Ruby
|