graphql 2.0.16 → 2.0.17
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.
Potentially problematic release.
This version of graphql might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/graphql/analysis/ast/visitor.rb +42 -35
- data/lib/graphql/execution/interpreter/runtime.rb +14 -4
- data/lib/graphql/execution/interpreter.rb +10 -0
- data/lib/graphql/execution/lazy.rb +4 -8
- data/lib/graphql/introspection/directive_type.rb +2 -2
- data/lib/graphql/introspection/field_type.rb +1 -1
- data/lib/graphql/introspection/schema_type.rb +2 -2
- data/lib/graphql/introspection/type_type.rb +5 -5
- data/lib/graphql/language/nodes.rb +39 -31
- data/lib/graphql/language/visitor.rb +191 -83
- data/lib/graphql/schema/argument.rb +0 -4
- data/lib/graphql/schema/directive.rb +12 -2
- data/lib/graphql/schema/enum.rb +24 -17
- data/lib/graphql/schema/enum_value.rb +5 -3
- data/lib/graphql/schema/field.rb +22 -26
- data/lib/graphql/schema/interface.rb +0 -10
- data/lib/graphql/schema/late_bound_type.rb +2 -0
- data/lib/graphql/schema/member/base_dsl_methods.rb +15 -14
- data/lib/graphql/schema/member/has_arguments.rb +104 -57
- data/lib/graphql/schema/member/has_fields.rb +8 -1
- data/lib/graphql/schema/member/has_interfaces.rb +49 -8
- data/lib/graphql/schema/member/has_validators.rb +31 -5
- data/lib/graphql/schema/member/type_system_helpers.rb +17 -0
- data/lib/graphql/schema/warden.rb +18 -3
- data/lib/graphql/schema.rb +3 -19
- data/lib/graphql/static_validation/literal_validator.rb +15 -1
- data/lib/graphql/subscriptions/event.rb +2 -7
- data/lib/graphql/types/relay/connection_behaviors.rb +0 -4
- data/lib/graphql/types/relay/edge_behaviors.rb +0 -4
- data/lib/graphql/types/string.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- metadata +3 -3
@@ -11,6 +11,7 @@ module GraphQL
|
|
11
11
|
def self.extended(cls)
|
12
12
|
cls.extend(ArgumentClassAccessor)
|
13
13
|
cls.include(ArgumentObjectLoader)
|
14
|
+
cls.extend(ClassConfigured)
|
14
15
|
end
|
15
16
|
|
16
17
|
# @see {GraphQL::Schema::Argument#initialize} for parameters
|
@@ -109,14 +110,6 @@ module GraphQL
|
|
109
110
|
|
110
111
|
# @return [Hash<String => GraphQL::Schema::Argument] Arguments defined on this thing, keyed by name. Includes inherited definitions
|
111
112
|
def arguments(context = GraphQL::Query::NullContext)
|
112
|
-
inherited_arguments = if self.is_a?(Class) && superclass.respond_to?(:arguments)
|
113
|
-
superclass.arguments(context)
|
114
|
-
elsif defined?(@resolver_class) && @resolver_class
|
115
|
-
@resolver_class.field_arguments(context)
|
116
|
-
else
|
117
|
-
nil
|
118
|
-
end
|
119
|
-
# Local definitions override inherited ones
|
120
113
|
if own_arguments.any?
|
121
114
|
own_arguments_that_apply = {}
|
122
115
|
own_arguments.each do |name, args_entry|
|
@@ -125,47 +118,107 @@ module GraphQL
|
|
125
118
|
end
|
126
119
|
end
|
127
120
|
end
|
121
|
+
# might be nil if there are actually no arguments
|
122
|
+
own_arguments_that_apply || own_arguments
|
123
|
+
end
|
128
124
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
125
|
+
module ClassConfigured
|
126
|
+
def inherited(child_class)
|
127
|
+
super
|
128
|
+
child_class.extend(InheritedArguments)
|
129
|
+
end
|
130
|
+
|
131
|
+
module InheritedArguments
|
132
|
+
def arguments(context = GraphQL::Query::NullContext)
|
133
|
+
own_arguments = super
|
134
|
+
inherited_arguments = superclass.arguments(context)
|
135
|
+
|
136
|
+
if own_arguments.any?
|
137
|
+
if inherited_arguments.any?
|
138
|
+
# Local definitions override inherited ones
|
139
|
+
inherited_arguments.merge(own_arguments)
|
140
|
+
else
|
141
|
+
own_arguments
|
142
|
+
end
|
143
|
+
else
|
144
|
+
inherited_arguments
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def all_argument_definitions
|
149
|
+
all_defns = {}
|
150
|
+
ancestors.reverse_each do |ancestor|
|
151
|
+
if ancestor.respond_to?(:own_arguments)
|
152
|
+
all_defns.merge!(ancestor.own_arguments)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
all_defns = all_defns.values
|
156
|
+
all_defns.flatten!
|
157
|
+
all_defns
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
def get_argument(argument_name, context = GraphQL::Query::NullContext)
|
162
|
+
warden = Warden.from_context(context)
|
163
|
+
for ancestor in ancestors
|
164
|
+
if ancestor.respond_to?(:own_arguments) &&
|
165
|
+
(a = ancestor.own_arguments[argument_name]) &&
|
166
|
+
(a = Warden.visible_entry?(:visible_argument?, a, context, warden))
|
167
|
+
return a
|
168
|
+
end
|
169
|
+
end
|
170
|
+
nil
|
134
171
|
end
|
135
|
-
else
|
136
|
-
# might be nil if there are actually no arguments
|
137
|
-
own_arguments_that_apply || own_arguments
|
138
172
|
end
|
139
173
|
end
|
140
174
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
175
|
+
module FieldConfigured
|
176
|
+
def arguments(context = GraphQL::Query::NullContext)
|
177
|
+
own_arguments = super
|
178
|
+
if defined?(@resolver_class) && @resolver_class
|
179
|
+
inherited_arguments = @resolver_class.field_arguments(context)
|
180
|
+
if own_arguments.any?
|
181
|
+
if inherited_arguments.any?
|
182
|
+
inherited_arguments.merge(own_arguments)
|
183
|
+
else
|
184
|
+
own_arguments
|
185
|
+
end
|
186
|
+
else
|
187
|
+
inherited_arguments
|
147
188
|
end
|
189
|
+
else
|
190
|
+
own_arguments
|
148
191
|
end
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
192
|
+
end
|
193
|
+
|
194
|
+
def all_argument_definitions
|
195
|
+
if defined?(@resolver_class) && @resolver_class
|
196
|
+
all_defns = {}
|
197
|
+
@resolver_class.all_field_argument_definitions.each do |arg_defn|
|
198
|
+
key = arg_defn.graphql_name
|
199
|
+
case (current_value = all_defns[key])
|
200
|
+
when nil
|
201
|
+
all_defns[key] = arg_defn
|
202
|
+
when Array
|
203
|
+
current_value << arg_defn
|
204
|
+
when GraphQL::Schema::Argument
|
205
|
+
all_defns[key] = [current_value, arg_defn]
|
206
|
+
else
|
207
|
+
raise "Invariant: Unexpected argument definition, #{current_value.class}: #{current_value.inspect}"
|
208
|
+
end
|
162
209
|
end
|
210
|
+
all_defns.merge!(own_arguments)
|
211
|
+
all_defns = all_defns.values
|
212
|
+
all_defns.flatten!
|
213
|
+
all_defns
|
214
|
+
else
|
215
|
+
super
|
163
216
|
end
|
164
|
-
all_defns.merge!(own_arguments)
|
165
|
-
else
|
166
|
-
all_defns = own_arguments
|
167
217
|
end
|
168
|
-
|
218
|
+
end
|
219
|
+
|
220
|
+
def all_argument_definitions
|
221
|
+
all_defns = own_arguments.values
|
169
222
|
all_defns.flatten!
|
170
223
|
all_defns
|
171
224
|
end
|
@@ -173,22 +226,11 @@ module GraphQL
|
|
173
226
|
# @return [GraphQL::Schema::Argument, nil] Argument defined on this thing, fetched by name.
|
174
227
|
def get_argument(argument_name, context = GraphQL::Query::NullContext)
|
175
228
|
warden = Warden.from_context(context)
|
176
|
-
if
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
@resolver_class.get_field_argument(argument_name, context)
|
181
|
-
else
|
182
|
-
nil
|
183
|
-
end
|
229
|
+
if (arg_config = own_arguments[argument_name]) && (visible_arg = Warden.visible_entry?(:visible_argument?, arg_config, context, warden))
|
230
|
+
visible_arg
|
231
|
+
elsif defined?(@resolver_class) && @resolver_class
|
232
|
+
@resolver_class.get_field_argument(argument_name, context)
|
184
233
|
else
|
185
|
-
for ancestor in ancestors
|
186
|
-
if ancestor.respond_to?(:own_arguments) &&
|
187
|
-
(a = ancestor.own_arguments[argument_name]) &&
|
188
|
-
(a = Warden.visible_entry?(:visible_argument?, a, context, warden))
|
189
|
-
return a
|
190
|
-
end
|
191
|
-
end
|
192
234
|
nil
|
193
235
|
end
|
194
236
|
end
|
@@ -209,7 +251,7 @@ module GraphQL
|
|
209
251
|
# @return [Interpreter::Arguments, Execution::Lazy<Interpeter::Arguments>]
|
210
252
|
def coerce_arguments(parent_object, values, context, &block)
|
211
253
|
# Cache this hash to avoid re-merging it
|
212
|
-
arg_defns =
|
254
|
+
arg_defns = context.warden.arguments(self)
|
213
255
|
total_args_count = arg_defns.size
|
214
256
|
|
215
257
|
finished_args = nil
|
@@ -223,7 +265,7 @@ module GraphQL
|
|
223
265
|
argument_values = {}
|
224
266
|
resolved_args_count = 0
|
225
267
|
raised_error = false
|
226
|
-
arg_defns.each do |
|
268
|
+
arg_defns.each do |arg_defn|
|
227
269
|
context.dataloader.append_job do
|
228
270
|
begin
|
229
271
|
arg_defn.coerce_into_values(parent_object, values, context, argument_values)
|
@@ -265,7 +307,12 @@ module GraphQL
|
|
265
307
|
# but not for directives.
|
266
308
|
# TODO apply static validations on schema definitions?
|
267
309
|
def validate_directive_argument(arg_defn, value)
|
268
|
-
|
310
|
+
# this is only implemented on directives.
|
311
|
+
nil
|
312
|
+
end
|
313
|
+
|
314
|
+
module HasDirectiveArguments
|
315
|
+
def validate_directive_argument(arg_defn, value)
|
269
316
|
if value.nil? && arg_defn.type.non_null?
|
270
317
|
raise ArgumentError, "#{arg_defn.path} is required, but no value was given"
|
271
318
|
end
|
@@ -129,12 +129,19 @@ module GraphQL
|
|
129
129
|
|
130
130
|
private
|
131
131
|
|
132
|
+
def inherited(subclass)
|
133
|
+
super
|
134
|
+
subclass.class_eval do
|
135
|
+
@own_fields ||= nil
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
132
139
|
# If `type` is an interface, and `self` has a type membership for `type`, then make sure it's visible.
|
133
140
|
def visible_interface_implementation?(type, context, warden)
|
134
141
|
if type.respond_to?(:kind) && type.kind.interface?
|
135
142
|
implements_this_interface = false
|
136
143
|
implementation_is_visible = false
|
137
|
-
interface_type_memberships.each do |tm|
|
144
|
+
warden.interface_type_memberships(self, context).each do |tm|
|
138
145
|
if tm.abstract_type == type
|
139
146
|
implements_this_interface ||= true
|
140
147
|
if warden.visible_type_membership?(tm, context)
|
@@ -55,7 +55,38 @@ module GraphQL
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def interface_type_memberships
|
58
|
-
own_interface_type_memberships
|
58
|
+
own_interface_type_memberships
|
59
|
+
end
|
60
|
+
|
61
|
+
module ClassConfigured
|
62
|
+
# This combination of extended -> inherited -> extended
|
63
|
+
# means that the base class (`Schema::Object`) *won't*
|
64
|
+
# have the superclass-related code in `InheritedInterfaces`,
|
65
|
+
# but child classes of `Schema::Object` will have it.
|
66
|
+
# That way, we don't need a `superclass.respond_to?(...)` check.
|
67
|
+
def inherited(child_class)
|
68
|
+
super
|
69
|
+
child_class.extend(InheritedInterfaces)
|
70
|
+
end
|
71
|
+
|
72
|
+
module InheritedInterfaces
|
73
|
+
def interfaces(context = GraphQL::Query::NullContext)
|
74
|
+
visible_interfaces = super
|
75
|
+
visible_interfaces.concat(superclass.interfaces(context))
|
76
|
+
visible_interfaces.uniq!
|
77
|
+
visible_interfaces
|
78
|
+
end
|
79
|
+
|
80
|
+
def interface_type_memberships
|
81
|
+
own_tms = super
|
82
|
+
inherited_tms = superclass.interface_type_memberships
|
83
|
+
if inherited_tms.size > 0
|
84
|
+
own_tms + inherited_tms
|
85
|
+
else
|
86
|
+
own_tms
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
59
90
|
end
|
60
91
|
|
61
92
|
# param context [Query::Context] If omitted, skip filtering.
|
@@ -63,24 +94,34 @@ module GraphQL
|
|
63
94
|
warden = Warden.from_context(context)
|
64
95
|
visible_interfaces = []
|
65
96
|
own_interface_type_memberships.each do |type_membership|
|
66
|
-
# During initialization, `type_memberships` can hold late-bound types
|
67
97
|
case type_membership
|
68
|
-
when String, Schema::LateBoundType
|
69
|
-
visible_interfaces << type_membership
|
70
98
|
when Schema::TypeMembership
|
71
99
|
if warden.visible_type_membership?(type_membership, context)
|
72
100
|
visible_interfaces << type_membership.abstract_type
|
73
101
|
end
|
102
|
+
when String, Schema::LateBoundType
|
103
|
+
# During initialization, `type_memberships` can hold late-bound types
|
104
|
+
visible_interfaces << type_membership
|
74
105
|
else
|
75
106
|
raise "Invariant: Unexpected type_membership #{type_membership.class}: #{type_membership.inspect}"
|
76
107
|
end
|
77
108
|
end
|
109
|
+
visible_interfaces.uniq!
|
78
110
|
|
79
|
-
|
80
|
-
|
81
|
-
end
|
111
|
+
visible_interfaces
|
112
|
+
end
|
82
113
|
|
83
|
-
|
114
|
+
private
|
115
|
+
|
116
|
+
def self.extended(child_class)
|
117
|
+
child_class.extend(ClassConfigured)
|
118
|
+
end
|
119
|
+
|
120
|
+
def inherited(subclass)
|
121
|
+
super
|
122
|
+
subclass.class_eval do
|
123
|
+
@own_interface_type_memberships ||= nil
|
124
|
+
end
|
84
125
|
end
|
85
126
|
end
|
86
127
|
end
|
@@ -18,12 +18,38 @@ module GraphQL
|
|
18
18
|
|
19
19
|
# @return [Array<GraphQL::Schema::Validator>]
|
20
20
|
def validators
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
@own_validators || EMPTY_ARRAY
|
22
|
+
end
|
23
|
+
|
24
|
+
module ClassConfigured
|
25
|
+
def inherited(child_cls)
|
26
|
+
super
|
27
|
+
child_cls.extend(ClassValidators)
|
26
28
|
end
|
29
|
+
|
30
|
+
module ClassValidators
|
31
|
+
include Schema::FindInheritedValue::EmptyObjects
|
32
|
+
|
33
|
+
def validators
|
34
|
+
inherited_validators = superclass.validators
|
35
|
+
if inherited_validators.any?
|
36
|
+
if @own_validators.nil?
|
37
|
+
inherited_validators
|
38
|
+
else
|
39
|
+
inherited_validators + @own_validators
|
40
|
+
end
|
41
|
+
elsif @own_validators.nil?
|
42
|
+
EMPTY_ARRAY
|
43
|
+
else
|
44
|
+
@own_validators
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.extended(child_cls)
|
51
|
+
super
|
52
|
+
child_cls.extend(ClassConfigured)
|
27
53
|
end
|
28
54
|
end
|
29
55
|
end
|
@@ -4,6 +4,13 @@ module GraphQL
|
|
4
4
|
class Schema
|
5
5
|
class Member
|
6
6
|
module TypeSystemHelpers
|
7
|
+
def initialize(*args, &block)
|
8
|
+
super
|
9
|
+
@to_non_null_type ||= nil
|
10
|
+
@to_list_type ||= nil
|
11
|
+
end
|
12
|
+
ruby2_keywords :initialize if respond_to?(:ruby2_keywords, true)
|
13
|
+
|
7
14
|
# @return [Schema::NonNull] Make a non-null-type representation of this type
|
8
15
|
def to_non_null_type
|
9
16
|
@to_non_null_type ||= GraphQL::Schema::NonNull.new(self)
|
@@ -32,6 +39,16 @@ module GraphQL
|
|
32
39
|
def kind
|
33
40
|
raise GraphQL::RequiredImplementationMissingError, "No `.kind` defined for #{self}"
|
34
41
|
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def inherited(subclass)
|
46
|
+
super
|
47
|
+
subclass.class_eval do
|
48
|
+
@to_non_null_type ||= nil
|
49
|
+
@to_list_type ||= nil
|
50
|
+
end
|
51
|
+
end
|
35
52
|
end
|
36
53
|
end
|
37
54
|
end
|
@@ -80,6 +80,8 @@ module GraphQL
|
|
80
80
|
def visible_type?(type, ctx); type.visible?(ctx); end
|
81
81
|
def visible_enum_value?(ev, ctx); ev.visible?(ctx); end
|
82
82
|
def visible_type_membership?(tm, ctx); tm.visible?(ctx); end
|
83
|
+
def interface_type_memberships(obj_t, ctx); obj_t.interface_type_memberships; end
|
84
|
+
def arguments(owner, ctx); owner.arguments(ctx); end
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
@@ -174,14 +176,20 @@ module GraphQL
|
|
174
176
|
|
175
177
|
# @param argument_owner [GraphQL::Field, GraphQL::InputObjectType]
|
176
178
|
# @return [Array<GraphQL::Argument>] Visible arguments on `argument_owner`
|
177
|
-
def arguments(argument_owner)
|
178
|
-
@visible_arguments ||= read_through { |o| o.arguments(@context).each_value.select { |a| visible_argument?(a) } }
|
179
|
+
def arguments(argument_owner, ctx = nil)
|
180
|
+
@visible_arguments ||= read_through { |o| o.arguments(@context).each_value.select { |a| visible_argument?(a, @context) } }
|
179
181
|
@visible_arguments[argument_owner]
|
180
182
|
end
|
181
183
|
|
182
184
|
# @return [Array<GraphQL::EnumType::EnumValue>] Visible members of `enum_defn`
|
183
185
|
def enum_values(enum_defn)
|
184
|
-
@visible_enum_arrays ||= read_through { |e|
|
186
|
+
@visible_enum_arrays ||= read_through { |e|
|
187
|
+
values = e.enum_values(@context)
|
188
|
+
if values.size == 0
|
189
|
+
raise GraphQL::Schema::Enum::MissingValuesError.new(e)
|
190
|
+
end
|
191
|
+
values
|
192
|
+
}
|
185
193
|
@visible_enum_arrays[enum_defn]
|
186
194
|
end
|
187
195
|
|
@@ -233,6 +241,13 @@ module GraphQL
|
|
233
241
|
visible?(type_membership)
|
234
242
|
end
|
235
243
|
|
244
|
+
def interface_type_memberships(obj_type, _ctx = nil)
|
245
|
+
@type_memberships ||= read_through do |obj_t|
|
246
|
+
obj_t.interface_type_memberships
|
247
|
+
end
|
248
|
+
@type_memberships[obj_type]
|
249
|
+
end
|
250
|
+
|
236
251
|
private
|
237
252
|
|
238
253
|
def visible_and_reachable_type?(type_defn)
|
data/lib/graphql/schema.rb
CHANGED
@@ -62,7 +62,7 @@ module GraphQL
|
|
62
62
|
# Schemas can specify how queries should be executed against them.
|
63
63
|
# `query_execution_strategy`, `mutation_execution_strategy` and `subscription_execution_strategy`
|
64
64
|
# each apply to corresponding root types.
|
65
|
-
#
|
65
|
+
#
|
66
66
|
# @example defining a schema
|
67
67
|
# class MySchema < GraphQL::Schema
|
68
68
|
# query QueryType
|
@@ -755,7 +755,7 @@ module GraphQL
|
|
755
755
|
if handler
|
756
756
|
obj = context[:current_object]
|
757
757
|
args = context[:current_arguments]
|
758
|
-
args = args && args.keyword_arguments
|
758
|
+
args = args && args.respond_to?(:keyword_arguments) ? args.keyword_arguments : nil
|
759
759
|
field = context[:current_field]
|
760
760
|
if obj.is_a?(GraphQL::Schema::Object)
|
761
761
|
obj = obj.object
|
@@ -826,10 +826,6 @@ module GraphQL
|
|
826
826
|
member.visible?(ctx)
|
827
827
|
end
|
828
828
|
|
829
|
-
def accessible?(member, ctx)
|
830
|
-
member.accessible?(ctx)
|
831
|
-
end
|
832
|
-
|
833
829
|
def schema_directive(dir_class, **options)
|
834
830
|
@own_schema_directives ||= []
|
835
831
|
Member::HasDirectives.add_directive(self, @own_schema_directives, dir_class, options)
|
@@ -839,18 +835,6 @@ module GraphQL
|
|
839
835
|
Member::HasDirectives.get_directives(self, @own_schema_directives, :schema_directives)
|
840
836
|
end
|
841
837
|
|
842
|
-
# This hook is called when a client tries to access one or more
|
843
|
-
# fields that fail the `accessible?` check.
|
844
|
-
#
|
845
|
-
# By default, an error is added to the response. Override this hook to
|
846
|
-
# track metrics or return a different error to the client.
|
847
|
-
#
|
848
|
-
# @param error [InaccessibleFieldsError] The analysis error for this check
|
849
|
-
# @return [AnalysisError, nil] Return an error to skip the query
|
850
|
-
def inaccessible_fields(error)
|
851
|
-
error
|
852
|
-
end
|
853
|
-
|
854
838
|
# This hook is called when an object fails an `authorized?` check.
|
855
839
|
# You might report to your bug tracker here, so you can correct
|
856
840
|
# the field resolvers not to return unauthorized objects.
|
@@ -900,7 +884,7 @@ module GraphQL
|
|
900
884
|
# A function to call when {#execute} receives an invalid query string
|
901
885
|
#
|
902
886
|
# The default is to add the error to `context.errors`
|
903
|
-
# @param
|
887
|
+
# @param parse_err [GraphQL::ParseError] The error encountered during parsing
|
904
888
|
# @param ctx [GraphQL::Query::Context] The context for the query where the error occurred
|
905
889
|
# @return void
|
906
890
|
def parse_error(parse_err, ctx)
|
@@ -18,6 +18,19 @@ module GraphQL
|
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
+
def replace_nulls_in(ast_value)
|
22
|
+
case ast_value
|
23
|
+
when Array
|
24
|
+
ast_value.map { |v| replace_nulls_in(v) }
|
25
|
+
when GraphQL::Language::Nodes::InputObject
|
26
|
+
ast_value.to_h
|
27
|
+
when GraphQL::Language::Nodes::NullValue
|
28
|
+
nil
|
29
|
+
else
|
30
|
+
ast_value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
21
34
|
def recursively_validate(ast_value, type)
|
22
35
|
if type.nil?
|
23
36
|
# this means we're an undefined argument, see #present_input_field_values_are_valid
|
@@ -42,7 +55,8 @@ module GraphQL
|
|
42
55
|
@valid_response
|
43
56
|
elsif type.kind.scalar? && constant_scalar?(ast_value)
|
44
57
|
maybe_raise_if_invalid(ast_value) do
|
45
|
-
|
58
|
+
ruby_value = replace_nulls_in(ast_value)
|
59
|
+
type.validate_input(ruby_value, @context)
|
46
60
|
end
|
47
61
|
elsif type.kind.enum?
|
48
62
|
maybe_raise_if_invalid(ast_value) do
|
@@ -100,13 +100,8 @@ module GraphQL
|
|
100
100
|
arg_name = k.to_s
|
101
101
|
camelized_arg_name = GraphQL::Schema::Member::BuildType.camelize(arg_name)
|
102
102
|
arg_defn = get_arg_definition(arg_owner, camelized_arg_name, context)
|
103
|
-
|
104
|
-
|
105
|
-
normalized_arg_name = camelized_arg_name
|
106
|
-
else
|
107
|
-
normalized_arg_name = arg_name
|
108
|
-
arg_defn = get_arg_definition(arg_owner, normalized_arg_name, context)
|
109
|
-
end
|
103
|
+
arg_defn ||= get_arg_definition(arg_owner, arg_name, context)
|
104
|
+
normalized_arg_name = arg_defn.graphql_name
|
110
105
|
arg_base_type = arg_defn.type.unwrap
|
111
106
|
# In the case where the value being emitted is seen as a "JSON"
|
112
107
|
# type, treat the value as one atomic unit of serialization
|
@@ -79,10 +79,6 @@ module GraphQL
|
|
79
79
|
true # Let nodes be filtered out
|
80
80
|
end
|
81
81
|
|
82
|
-
def accessible?(ctx)
|
83
|
-
node_type.accessible?(ctx)
|
84
|
-
end
|
85
|
-
|
86
82
|
def visible?(ctx)
|
87
83
|
# if this is an abstract base class, there may be no `node_type`
|
88
84
|
node_type ? node_type.visible?(ctx) : super
|
data/lib/graphql/types/string.rb
CHANGED
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: 2.0.
|
4
|
+
version: 2.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -597,7 +597,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
597
597
|
- !ruby/object:Gem::Version
|
598
598
|
version: '0'
|
599
599
|
requirements: []
|
600
|
-
rubygems_version: 3.
|
600
|
+
rubygems_version: 3.4.1
|
601
601
|
signing_key:
|
602
602
|
specification_version: 4
|
603
603
|
summary: A GraphQL language and runtime for Ruby
|