graphql 2.4.4 → 2.4.5
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/visitor.rb +1 -1
- data/lib/graphql/analysis.rb +3 -3
- data/lib/graphql/autoload.rb +37 -0
- data/lib/graphql/current.rb +1 -1
- data/lib/graphql/dataloader/async_dataloader.rb +4 -4
- data/lib/graphql/dataloader/source.rb +1 -1
- data/lib/graphql/dataloader.rb +6 -9
- data/lib/graphql/execution/interpreter/resolve.rb +3 -3
- data/lib/graphql/execution/interpreter/runtime.rb +7 -7
- data/lib/graphql/execution/interpreter.rb +4 -4
- data/lib/graphql/language/cache.rb +13 -0
- data/lib/graphql/language/document_from_schema_definition.rb +8 -7
- data/lib/graphql/language/lexer.rb +4 -1
- data/lib/graphql/language/printer.rb +8 -8
- data/lib/graphql/pagination/connection.rb +1 -1
- data/lib/graphql/query/context/scoped_context.rb +1 -1
- data/lib/graphql/query/context.rb +6 -5
- data/lib/graphql/query/variable_validation_error.rb +1 -1
- data/lib/graphql/query.rb +12 -10
- data/lib/graphql/railtie.rb +7 -0
- data/lib/graphql/schema/addition.rb +1 -1
- data/lib/graphql/schema/directive/flagged.rb +1 -1
- data/lib/graphql/schema/directive.rb +1 -1
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +10 -10
- data/lib/graphql/schema/field_extension.rb +1 -1
- data/lib/graphql/schema/has_single_input_argument.rb +3 -1
- data/lib/graphql/schema/input_object.rb +64 -27
- data/lib/graphql/schema/interface.rb +1 -1
- data/lib/graphql/schema/loader.rb +1 -1
- data/lib/graphql/schema/member/has_arguments.rb +12 -12
- data/lib/graphql/schema/member/has_directives.rb +3 -3
- data/lib/graphql/schema/member/has_fields.rb +18 -0
- data/lib/graphql/schema/member/has_interfaces.rb +4 -4
- data/lib/graphql/schema/member/has_validators.rb +1 -1
- data/lib/graphql/schema/object.rb +8 -0
- data/lib/graphql/schema/relay_classic_mutation.rb +0 -1
- data/lib/graphql/schema/resolver.rb +5 -5
- data/lib/graphql/schema/subscription.rb +2 -2
- data/lib/graphql/schema/union.rb +1 -1
- data/lib/graphql/schema/validator.rb +1 -1
- data/lib/graphql/schema/visibility/profile.rb +4 -2
- data/lib/graphql/schema/visibility/visit.rb +2 -2
- data/lib/graphql/schema/visibility.rb +33 -19
- data/lib/graphql/schema/warden.rb +4 -4
- data/lib/graphql/schema.rb +15 -9
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +1 -1
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -1
- data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +1 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +1 -1
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +1 -1
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +1 -1
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +1 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +1 -1
- data/lib/graphql/subscriptions.rb +1 -1
- data/lib/graphql/testing/helpers.rb +2 -2
- data/lib/graphql/types/relay/connection_behaviors.rb +2 -2
- data/lib/graphql/types/relay/edge_behaviors.rb +1 -1
- data/lib/graphql/types.rb +18 -11
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +80 -47
- metadata +3 -2
data/lib/graphql/schema/field.rb
CHANGED
@@ -42,8 +42,8 @@ module GraphQL
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def directives
|
45
|
-
if @resolver_class && (r_dirs = @resolver_class.directives).
|
46
|
-
if (own_dirs = super).
|
45
|
+
if @resolver_class && !(r_dirs = @resolver_class.directives).empty?
|
46
|
+
if !(own_dirs = super).empty?
|
47
47
|
own_dirs + r_dirs
|
48
48
|
else
|
49
49
|
r_dirs
|
@@ -81,7 +81,7 @@ module GraphQL
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def inspect
|
84
|
-
"#<#{self.class} #{path}#{all_argument_definitions.
|
84
|
+
"#<#{self.class} #{path}#{!all_argument_definitions.empty? ? "(...)" : ""}: #{type.to_type_signature}>"
|
85
85
|
end
|
86
86
|
|
87
87
|
alias :mutation :resolver
|
@@ -335,15 +335,15 @@ module GraphQL
|
|
335
335
|
@call_after_define = false
|
336
336
|
set_pagination_extensions(connection_extension: connection_extension)
|
337
337
|
# Do this last so we have as much context as possible when initializing them:
|
338
|
-
if extensions.
|
338
|
+
if !extensions.empty?
|
339
339
|
self.extensions(extensions)
|
340
340
|
end
|
341
341
|
|
342
|
-
if resolver_class && resolver_class.extensions.
|
342
|
+
if resolver_class && !resolver_class.extensions.empty?
|
343
343
|
self.extensions(resolver_class.extensions)
|
344
344
|
end
|
345
345
|
|
346
|
-
if directives.
|
346
|
+
if !directives.empty?
|
347
347
|
directives.each do |(dir_class, options)|
|
348
348
|
self.directive(dir_class, **options)
|
349
349
|
end
|
@@ -482,7 +482,7 @@ module GraphQL
|
|
482
482
|
if new_extras.nil?
|
483
483
|
# Read the value
|
484
484
|
field_extras = @extras
|
485
|
-
if @resolver_class &&
|
485
|
+
if @resolver_class && !@resolver_class.extras.empty?
|
486
486
|
field_extras + @resolver_class.extras
|
487
487
|
else
|
488
488
|
field_extras
|
@@ -732,7 +732,7 @@ module GraphQL
|
|
732
732
|
method_to_call = resolver_method
|
733
733
|
method_receiver = obj
|
734
734
|
# Call the method with kwargs, if there are any
|
735
|
-
if ruby_kwargs.
|
735
|
+
if !ruby_kwargs.empty?
|
736
736
|
obj.public_send(resolver_method, **ruby_kwargs)
|
737
737
|
else
|
738
738
|
obj.public_send(resolver_method)
|
@@ -752,7 +752,7 @@ module GraphQL
|
|
752
752
|
elsif inner_object.respond_to?(@method_sym)
|
753
753
|
method_to_call = @method_sym
|
754
754
|
method_receiver = obj.object
|
755
|
-
if ruby_kwargs.
|
755
|
+
if !ruby_kwargs.empty?
|
756
756
|
inner_object.public_send(@method_sym, **ruby_kwargs)
|
757
757
|
else
|
758
758
|
inner_object.public_send(@method_sym)
|
@@ -839,7 +839,7 @@ module GraphQL
|
|
839
839
|
unsatisfied_ruby_kwargs.clear
|
840
840
|
end
|
841
841
|
|
842
|
-
if unsatisfied_ruby_kwargs.
|
842
|
+
if !unsatisfied_ruby_kwargs.empty? || !unsatisfied_method_params.empty?
|
843
843
|
raise FieldImplementationFailed.new, <<-ERR
|
844
844
|
Failed to call `#{method_name.inspect}` on #{receiver.inspect} because the Ruby method params were incompatible with the GraphQL arguments:
|
845
845
|
|
@@ -32,7 +32,7 @@ module GraphQL
|
|
32
32
|
input_kwargs = {}
|
33
33
|
end
|
34
34
|
|
35
|
-
if input_kwargs.
|
35
|
+
if !input_kwargs.empty?
|
36
36
|
super(**input_kwargs)
|
37
37
|
else
|
38
38
|
super()
|
@@ -136,6 +136,8 @@ module GraphQL
|
|
136
136
|
super || "Autogenerated input type of #{self.mutation.graphql_name}"
|
137
137
|
end
|
138
138
|
end
|
139
|
+
# For compatibility, in case no arguments are defined:
|
140
|
+
has_no_arguments(true)
|
139
141
|
mutation(mutation_class)
|
140
142
|
# these might be inherited:
|
141
143
|
mutation_args.each do |arg|
|
@@ -10,6 +10,14 @@ module GraphQL
|
|
10
10
|
|
11
11
|
include GraphQL::Dig
|
12
12
|
|
13
|
+
# Raised when an InputObject doesn't have any arguments defined and hasn't explicitly opted out of this requirement
|
14
|
+
class ArgumentsAreRequiredError < GraphQL::Error
|
15
|
+
def initialize(input_object_type)
|
16
|
+
message = "Input Object types must have arguments, but #{input_object_type.graphql_name} doesn't have any. Define an argument for this type, remove it from your schema, or add `has_no_arguments(true)` to its definition."
|
17
|
+
super(message)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
13
21
|
# @return [GraphQL::Query::Context] The context for this query
|
14
22
|
attr_reader :context
|
15
23
|
# @return [GraphQL::Execution::Interpereter::Arguments] The underlying arguments instance
|
@@ -45,6 +53,16 @@ module GraphQL
|
|
45
53
|
to_h
|
46
54
|
end
|
47
55
|
|
56
|
+
def deconstruct_keys(keys = nil)
|
57
|
+
if keys.nil?
|
58
|
+
@ruby_style_hash
|
59
|
+
else
|
60
|
+
new_h = {}
|
61
|
+
keys.each { |k| @ruby_style_hash.key?(k) && new_h[k] = @ruby_style_hash[k] }
|
62
|
+
new_h
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
48
66
|
def prepare
|
49
67
|
if @context
|
50
68
|
object = @context[:current_object]
|
@@ -56,33 +74,6 @@ module GraphQL
|
|
56
74
|
end
|
57
75
|
end
|
58
76
|
|
59
|
-
def self.authorized?(obj, value, ctx)
|
60
|
-
# Authorize each argument (but this doesn't apply if `prepare` is implemented):
|
61
|
-
if value.respond_to?(:key?)
|
62
|
-
ctx.types.arguments(self).each do |input_obj_arg|
|
63
|
-
if value.key?(input_obj_arg.keyword) &&
|
64
|
-
!input_obj_arg.authorized?(obj, value[input_obj_arg.keyword], ctx)
|
65
|
-
return false
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
# It didn't early-return false:
|
70
|
-
true
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.one_of
|
74
|
-
if !one_of?
|
75
|
-
if all_argument_definitions.any? { |arg| arg.type.non_null? }
|
76
|
-
raise ArgumentError, "`one_of` may not be used with required arguments -- add `required: false` to argument definitions to use `one_of`"
|
77
|
-
end
|
78
|
-
directive(GraphQL::Schema::Directive::OneOf)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def self.one_of?
|
83
|
-
false # Re-defined when `OneOf` is added
|
84
|
-
end
|
85
|
-
|
86
77
|
def unwrap_value(value)
|
87
78
|
case value
|
88
79
|
when Array
|
@@ -121,6 +112,33 @@ module GraphQL
|
|
121
112
|
end
|
122
113
|
|
123
114
|
class << self
|
115
|
+
def authorized?(obj, value, ctx)
|
116
|
+
# Authorize each argument (but this doesn't apply if `prepare` is implemented):
|
117
|
+
if value.respond_to?(:key?)
|
118
|
+
ctx.types.arguments(self).each do |input_obj_arg|
|
119
|
+
if value.key?(input_obj_arg.keyword) &&
|
120
|
+
!input_obj_arg.authorized?(obj, value[input_obj_arg.keyword], ctx)
|
121
|
+
return false
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
# It didn't early-return false:
|
126
|
+
true
|
127
|
+
end
|
128
|
+
|
129
|
+
def one_of
|
130
|
+
if !one_of?
|
131
|
+
if all_argument_definitions.any? { |arg| arg.type.non_null? }
|
132
|
+
raise ArgumentError, "`one_of` may not be used with required arguments -- add `required: false` to argument definitions to use `one_of`"
|
133
|
+
end
|
134
|
+
directive(GraphQL::Schema::Directive::OneOf)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def one_of?
|
139
|
+
false # Re-defined when `OneOf` is added
|
140
|
+
end
|
141
|
+
|
124
142
|
def argument(*args, **kwargs, &block)
|
125
143
|
argument_defn = super(*args, **kwargs, &block)
|
126
144
|
if one_of?
|
@@ -246,6 +264,25 @@ module GraphQL
|
|
246
264
|
result
|
247
265
|
end
|
248
266
|
|
267
|
+
# @param new_has_no_arguments [Boolean] Call with `true` to make this InputObject type ignore the requirement to have any defined arguments.
|
268
|
+
# @return [void]
|
269
|
+
def has_no_arguments(new_has_no_arguments)
|
270
|
+
@has_no_arguments = new_has_no_arguments
|
271
|
+
nil
|
272
|
+
end
|
273
|
+
|
274
|
+
# @return [Boolean] `true` if `has_no_arguments(true)` was configued
|
275
|
+
def has_no_arguments?
|
276
|
+
@has_no_arguments
|
277
|
+
end
|
278
|
+
|
279
|
+
def arguments(context = GraphQL::Query::NullContext.instance, require_defined_arguments = true)
|
280
|
+
if require_defined_arguments && !has_no_arguments? && !any_arguments?
|
281
|
+
warn(GraphQL::Schema::InputObject::ArgumentsAreRequiredError.new(self).message + "\n\nThis will raise an error in a future GraphQL-Ruby version.")
|
282
|
+
end
|
283
|
+
super(context, false)
|
284
|
+
end
|
285
|
+
|
249
286
|
private
|
250
287
|
|
251
288
|
# Suppress redefinition warning for objectId arguments
|
@@ -90,7 +90,7 @@ module GraphQL
|
|
90
90
|
# @param types [Class, Module]
|
91
91
|
# @return [Array<Module, Class>] Implementers of this interface, if they're registered
|
92
92
|
def orphan_types(*types)
|
93
|
-
if types.
|
93
|
+
if !types.empty?
|
94
94
|
@orphan_types ||= []
|
95
95
|
@orphan_types.concat(types)
|
96
96
|
else
|
@@ -76,8 +76,8 @@ module GraphQL
|
|
76
76
|
end
|
77
77
|
|
78
78
|
# @return [Hash<String => GraphQL::Schema::Argument] Arguments defined on this thing, keyed by name. Includes inherited definitions
|
79
|
-
def arguments(context = GraphQL::Query::NullContext.instance)
|
80
|
-
if own_arguments.
|
79
|
+
def arguments(context = GraphQL::Query::NullContext.instance, _require_defined_arguments = nil)
|
80
|
+
if !own_arguments.empty?
|
81
81
|
own_arguments_that_apply = {}
|
82
82
|
own_arguments.each do |name, args_entry|
|
83
83
|
if (visible_defn = Warden.visible_entry?(:visible_argument?, args_entry, context))
|
@@ -90,7 +90,7 @@ module GraphQL
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def any_arguments?
|
93
|
-
own_arguments.
|
93
|
+
!own_arguments.empty?
|
94
94
|
end
|
95
95
|
|
96
96
|
module ClassConfigured
|
@@ -100,12 +100,12 @@ module GraphQL
|
|
100
100
|
end
|
101
101
|
|
102
102
|
module InheritedArguments
|
103
|
-
def arguments(context = GraphQL::Query::NullContext.instance)
|
104
|
-
own_arguments = super
|
105
|
-
inherited_arguments = superclass.arguments(context)
|
103
|
+
def arguments(context = GraphQL::Query::NullContext.instance, require_defined_arguments = true)
|
104
|
+
own_arguments = super(context, require_defined_arguments)
|
105
|
+
inherited_arguments = superclass.arguments(context, false)
|
106
106
|
|
107
|
-
if own_arguments.
|
108
|
-
if inherited_arguments.
|
107
|
+
if !own_arguments.empty?
|
108
|
+
if !inherited_arguments.empty?
|
109
109
|
# Local definitions override inherited ones
|
110
110
|
inherited_arguments.merge(own_arguments)
|
111
111
|
else
|
@@ -149,12 +149,12 @@ module GraphQL
|
|
149
149
|
end
|
150
150
|
|
151
151
|
module FieldConfigured
|
152
|
-
def arguments(context = GraphQL::Query::NullContext.instance)
|
152
|
+
def arguments(context = GraphQL::Query::NullContext.instance, _require_defined_arguments = nil)
|
153
153
|
own_arguments = super
|
154
154
|
if @resolver_class
|
155
155
|
inherited_arguments = @resolver_class.field_arguments(context)
|
156
|
-
if own_arguments.
|
157
|
-
if inherited_arguments.
|
156
|
+
if !own_arguments.empty?
|
157
|
+
if !inherited_arguments.empty?
|
158
158
|
inherited_arguments.merge(own_arguments)
|
159
159
|
else
|
160
160
|
own_arguments
|
@@ -198,7 +198,7 @@ module GraphQL
|
|
198
198
|
end
|
199
199
|
|
200
200
|
def all_argument_definitions
|
201
|
-
if own_arguments.
|
201
|
+
if !own_arguments.empty?
|
202
202
|
all_defns = own_arguments.values
|
203
203
|
all_defns.flatten!
|
204
204
|
all_defns
|
@@ -55,14 +55,14 @@ module GraphQL
|
|
55
55
|
else
|
56
56
|
GraphQL::EmptyObjects::EMPTY_ARRAY
|
57
57
|
end
|
58
|
-
if inherited_directives.
|
58
|
+
if !inherited_directives.empty? && directives
|
59
59
|
dirs = []
|
60
60
|
merge_directives(dirs, inherited_directives)
|
61
61
|
merge_directives(dirs, directives)
|
62
62
|
dirs
|
63
63
|
elsif directives
|
64
64
|
directives
|
65
|
-
elsif inherited_directives.
|
65
|
+
elsif !inherited_directives.empty?
|
66
66
|
inherited_directives
|
67
67
|
else
|
68
68
|
GraphQL::EmptyObjects::EMPTY_ARRAY
|
@@ -71,7 +71,7 @@ module GraphQL
|
|
71
71
|
dirs = nil
|
72
72
|
schema_member.ancestors.reverse_each do |ancestor|
|
73
73
|
if ancestor.respond_to?(:own_directives) &&
|
74
|
-
(anc_dirs = ancestor.own_directives).
|
74
|
+
!(anc_dirs = ancestor.own_directives).empty?
|
75
75
|
dirs ||= []
|
76
76
|
merge_directives(dirs, anc_dirs)
|
77
77
|
end
|
@@ -79,6 +79,18 @@ module GraphQL
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
# @param new_has_no_fields [Boolean] Call with `true` to make this Object type ignore the requirement to have any defined fields.
|
83
|
+
# @return [void]
|
84
|
+
def has_no_fields(new_has_no_fields)
|
85
|
+
@has_no_fields = new_has_no_fields
|
86
|
+
nil
|
87
|
+
end
|
88
|
+
|
89
|
+
# @return [Boolean] `true` if `has_no_fields(true)` was configued
|
90
|
+
def has_no_fields?
|
91
|
+
@has_no_fields
|
92
|
+
end
|
93
|
+
|
82
94
|
# @return [Hash<String => GraphQL::Schema::Field, Array<GraphQL::Schema::Field>>] Fields defined on this class _specifically_, not parent classes
|
83
95
|
def own_fields
|
84
96
|
@own_fields ||= {}
|
@@ -155,9 +167,11 @@ module GraphQL
|
|
155
167
|
warden = Warden.from_context(context)
|
156
168
|
# Local overrides take precedence over inherited fields
|
157
169
|
visible_fields = {}
|
170
|
+
had_any_fields_at_all = false
|
158
171
|
for ancestor in ancestors
|
159
172
|
if ancestor.respond_to?(:own_fields) && visible_interface_implementation?(ancestor, context, warden)
|
160
173
|
ancestor.own_fields.each do |field_name, fields_entry|
|
174
|
+
had_any_fields_at_all = true
|
161
175
|
# Choose the most local definition that passes `.visible?` --
|
162
176
|
# stop checking for fields by name once one has been found.
|
163
177
|
if !visible_fields.key?(field_name) && (f = Warden.visible_entry?(:visible_field?, fields_entry, context, warden))
|
@@ -166,6 +180,9 @@ module GraphQL
|
|
166
180
|
end
|
167
181
|
end
|
168
182
|
end
|
183
|
+
if !had_any_fields_at_all && !has_no_fields?
|
184
|
+
warn(GraphQL::Schema::Object::FieldsAreRequiredError.new(self).message + "\n\nThis will raise an error in a future GraphQL-Ruby version.")
|
185
|
+
end
|
169
186
|
visible_fields
|
170
187
|
end
|
171
188
|
end
|
@@ -188,6 +205,7 @@ module GraphQL
|
|
188
205
|
subclass.class_eval do
|
189
206
|
@own_fields ||= nil
|
190
207
|
@field_class ||= nil
|
208
|
+
@has_no_fields ||= false
|
191
209
|
end
|
192
210
|
end
|
193
211
|
|
@@ -24,7 +24,7 @@ module GraphQL
|
|
24
24
|
implements(next_interface)
|
25
25
|
end
|
26
26
|
elsif int.is_a?(String) || int.is_a?(GraphQL::Schema::LateBoundType)
|
27
|
-
if options.
|
27
|
+
if !options.empty?
|
28
28
|
raise ArgumentError, "`implements(...)` doesn't support options with late-loaded types yet. Remove #{options} and open an issue to request this feature."
|
29
29
|
end
|
30
30
|
new_memberships << int
|
@@ -73,13 +73,13 @@ module GraphQL
|
|
73
73
|
def interfaces(context = GraphQL::Query::NullContext.instance)
|
74
74
|
visible_interfaces = super
|
75
75
|
inherited_interfaces = superclass.interfaces(context)
|
76
|
-
if visible_interfaces.
|
77
|
-
if inherited_interfaces.
|
76
|
+
if !visible_interfaces.empty?
|
77
|
+
if !inherited_interfaces.empty?
|
78
78
|
visible_interfaces.concat(inherited_interfaces)
|
79
79
|
visible_interfaces.uniq!
|
80
80
|
end
|
81
81
|
visible_interfaces
|
82
|
-
elsif inherited_interfaces.
|
82
|
+
elsif !inherited_interfaces.empty?
|
83
83
|
inherited_interfaces
|
84
84
|
else
|
85
85
|
EmptyObjects::EMPTY_ARRAY
|
@@ -8,6 +8,14 @@ module GraphQL
|
|
8
8
|
extend GraphQL::Schema::Member::HasFields
|
9
9
|
extend GraphQL::Schema::Member::HasInterfaces
|
10
10
|
|
11
|
+
# Raised when an Object doesn't have any field defined and hasn't explicitly opted out of this requirement
|
12
|
+
class FieldsAreRequiredError < GraphQL::Error
|
13
|
+
def initialize(object_type)
|
14
|
+
message = "Object types must have fields, but #{object_type.graphql_name} doesn't have any. Define a field for this type, remove it from your schema, or add `has_no_fields(true)` to its definition."
|
15
|
+
super(message)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
11
19
|
# @return [Object] the application object this type is wrapping
|
12
20
|
attr_reader :object
|
13
21
|
|
@@ -67,7 +67,7 @@ module GraphQL
|
|
67
67
|
# @api private
|
68
68
|
def resolve_with_support(**args)
|
69
69
|
# First call the ready? hook which may raise
|
70
|
-
raw_ready_val = if args.
|
70
|
+
raw_ready_val = if !args.empty?
|
71
71
|
ready?(**args)
|
72
72
|
else
|
73
73
|
ready?
|
@@ -88,7 +88,7 @@ module GraphQL
|
|
88
88
|
@prepared_arguments = loaded_args
|
89
89
|
Schema::Validator.validate!(self.class.validators, object, context, loaded_args, as: @field)
|
90
90
|
# Then call `authorized?`, which may raise or may return a lazy object
|
91
|
-
raw_authorized_val = if loaded_args.
|
91
|
+
raw_authorized_val = if !loaded_args.empty?
|
92
92
|
authorized?(**loaded_args)
|
93
93
|
else
|
94
94
|
authorized?
|
@@ -117,7 +117,7 @@ module GraphQL
|
|
117
117
|
|
118
118
|
# @api private {GraphQL::Schema::Mutation} uses this to clear the dataloader cache
|
119
119
|
def call_resolve(args_hash)
|
120
|
-
if args_hash.
|
120
|
+
if !args_hash.empty?
|
121
121
|
public_send(self.class.resolve_method, **args_hash)
|
122
122
|
else
|
123
123
|
public_send(self.class.resolve_method)
|
@@ -208,7 +208,7 @@ module GraphQL
|
|
208
208
|
end
|
209
209
|
|
210
210
|
# Avoid returning a lazy if none are needed
|
211
|
-
if prepare_lazies.
|
211
|
+
if !prepare_lazies.empty?
|
212
212
|
GraphQL::Execution::Lazy.all(prepare_lazies).then { prepared_args }
|
213
213
|
else
|
214
214
|
prepared_args
|
@@ -394,7 +394,7 @@ module GraphQL
|
|
394
394
|
if superclass.respond_to?(:extensions)
|
395
395
|
s_exts = superclass.extensions
|
396
396
|
if own_exts
|
397
|
-
if s_exts.
|
397
|
+
if !s_exts.empty?
|
398
398
|
own_exts + s_exts
|
399
399
|
else
|
400
400
|
own_exts
|
@@ -55,7 +55,7 @@ module GraphQL
|
|
55
55
|
|
56
56
|
# Wrap the user-defined `#subscribe` hook
|
57
57
|
def resolve_subscribe(**args)
|
58
|
-
ret_val = args.
|
58
|
+
ret_val = !args.empty? ? subscribe(**args) : subscribe
|
59
59
|
if ret_val == :no_response
|
60
60
|
context.skip
|
61
61
|
else
|
@@ -72,7 +72,7 @@ module GraphQL
|
|
72
72
|
|
73
73
|
# Wrap the user-provided `#update` hook
|
74
74
|
def resolve_update(**args)
|
75
|
-
ret_val = args.
|
75
|
+
ret_val = !args.empty? ? update(**args) : update
|
76
76
|
if ret_val == NO_UPDATE
|
77
77
|
context.namespace(:subscriptions)[:no_update] = true
|
78
78
|
context.skip
|
data/lib/graphql/schema/union.rb
CHANGED
@@ -11,7 +11,7 @@ module GraphQL
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def possible_types(*types, context: GraphQL::Query::NullContext.instance, **options)
|
14
|
-
if types.
|
14
|
+
if !types.empty?
|
15
15
|
types.each do |t|
|
16
16
|
assert_valid_union_member(t)
|
17
17
|
type_memberships << type_membership_class.new(self, t, **options)
|
@@ -111,7 +111,7 @@ module GraphQL
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def type(type_name)
|
114
|
-
t = @schema.visibility.get_type(type_name) # rubocop:disable ContextIsPassedCop
|
114
|
+
t = @schema.visibility.get_type(type_name) # rubocop:disable Development/ContextIsPassedCop
|
115
115
|
if t
|
116
116
|
if t.is_a?(Array)
|
117
117
|
vis_t = nil
|
@@ -239,7 +239,9 @@ module GraphQL
|
|
239
239
|
end
|
240
240
|
|
241
241
|
def directives
|
242
|
-
@all_directives ||= @schema.visibility.all_directives.select { |dir|
|
242
|
+
@all_directives ||= @schema.visibility.all_directives.select { |dir|
|
243
|
+
@cached_visible[dir] && @schema.visibility.all_references[dir].any? { |ref| ref == true || (@cached_visible[ref] && referenced?(ref)) }
|
244
|
+
}
|
243
245
|
end
|
244
246
|
|
245
247
|
def loadable?(t, _ctx)
|
@@ -35,7 +35,7 @@ module GraphQL
|
|
35
35
|
@late_bound_types = []
|
36
36
|
directives_to_visit = directives
|
37
37
|
|
38
|
-
while
|
38
|
+
while !@unvisited_types.empty? || !@late_bound_types.empty?
|
39
39
|
while (type = @unvisited_types.pop)
|
40
40
|
if @visited_types.add?(type) && @visit_block.call(type)
|
41
41
|
directives_to_visit.concat(type.directives)
|
@@ -156,7 +156,7 @@ module GraphQL
|
|
156
156
|
pt << owner
|
157
157
|
end
|
158
158
|
int.interfaces.each do |indirect_int|
|
159
|
-
if indirect_int.is_a?(LateBoundType) && (indirect_int_type = get_type(indirect_int.graphql_name)) # rubocop:disable ContextIsPassedCop
|
159
|
+
if indirect_int.is_a?(LateBoundType) && (indirect_int_type = get_type(indirect_int.graphql_name)) # rubocop:disable Development/ContextIsPassedCop
|
160
160
|
update_type_owner(owner, indirect_int_type)
|
161
161
|
end
|
162
162
|
end
|