graphql 2.0.11 → 2.0.12
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/execution/interpreter/runtime.rb +8 -4
- data/lib/graphql/language/printer.rb +8 -5
- data/lib/graphql/query/validation_pipeline.rb +4 -0
- data/lib/graphql/query.rb +10 -1
- data/lib/graphql/schema/argument.rb +10 -10
- data/lib/graphql/schema/member/has_arguments.rb +8 -2
- data/lib/graphql/schema.rb +10 -2
- data/lib/graphql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d299fcfe61f486f9370dac7dfcd66df417ca4697932d7861822fb12c61a5889
|
4
|
+
data.tar.gz: 45e03854d6248c63f80d3b80e141a28970303516ab5f78375d9d3362b9e04ba5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d756a4c5213a8e17910233b0e472a037b6dad007676f5399f6192b93df53e78611915bd066ac619b59d7d44a0f35efbd7bb329cb4189246bce0c077f584b049b
|
7
|
+
data.tar.gz: 277f7623f5bcc351bed49b3e95156166e16a92c3041a905f1e88399b15839eff8a0c733c16f4ae33c82213a4a47c3184d5c763e43ac2ca01a613caa419000513
|
@@ -685,12 +685,16 @@ module GraphQL
|
|
685
685
|
set_result(selection_result, result_name, r)
|
686
686
|
r
|
687
687
|
when "UNION", "INTERFACE"
|
688
|
-
resolved_type_or_lazy
|
689
|
-
|
688
|
+
resolved_type_or_lazy = resolve_type(current_type, value, path)
|
689
|
+
after_lazy(resolved_type_or_lazy, owner: current_type, path: path, ast_node: ast_node, field: field, owner_object: owner_object, arguments: arguments, trace: false, result_name: result_name, result: selection_result) do |resolved_type_result|
|
690
|
+
if resolved_type_result.is_a?(Array) && resolved_type_result.length == 2
|
691
|
+
resolved_type, resolved_value = resolved_type_result
|
692
|
+
else
|
693
|
+
resolved_type = resolved_type_result
|
694
|
+
resolved_value = value
|
695
|
+
end
|
690
696
|
|
691
|
-
after_lazy(resolved_type_or_lazy, owner: current_type, path: path, ast_node: ast_node, field: field, owner_object: owner_object, arguments: arguments, trace: false, result_name: result_name, result: selection_result) do |resolved_type|
|
692
697
|
possible_types = query.possible_types(current_type)
|
693
|
-
|
694
698
|
if !possible_types.include?(resolved_type)
|
695
699
|
parent_type = field.owner_type
|
696
700
|
err_class = current_type::UnresolvedTypeError
|
@@ -236,12 +236,15 @@ module GraphQL
|
|
236
236
|
out = print_description(input_object_type)
|
237
237
|
out << "input #{input_object_type.name}"
|
238
238
|
out << print_directives(input_object_type.directives)
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
239
|
+
if !input_object_type.fields.empty?
|
240
|
+
out << " {\n"
|
241
|
+
input_object_type.fields.each.with_index do |field, i|
|
242
|
+
out << print_description(field, indent: ' ', first_in_block: i == 0)
|
243
|
+
out << " #{print_input_value_definition(field)}\n"
|
244
|
+
end
|
245
|
+
out << "}"
|
243
246
|
end
|
244
|
-
out
|
247
|
+
out
|
245
248
|
end
|
246
249
|
|
247
250
|
def print_directive_definition(directive)
|
data/lib/graphql/query.rb
CHANGED
@@ -34,7 +34,16 @@ module GraphQL
|
|
34
34
|
attr_accessor :operation_name
|
35
35
|
|
36
36
|
# @return [Boolean] if false, static validation is skipped (execution behavior for invalid queries is undefined)
|
37
|
-
|
37
|
+
attr_reader :validate
|
38
|
+
|
39
|
+
# @param new_validate [Boolean] if false, static validation is skipped. This can't be reasssigned after validation.
|
40
|
+
def validate=(new_validate)
|
41
|
+
if defined?(@validation_pipeline) && @validation_pipeline && @validation_pipeline.has_validated?
|
42
|
+
raise ArgumentError, "Can't reassign Query#validate= after validation has run, remove this assignment."
|
43
|
+
else
|
44
|
+
@validate = new_validate
|
45
|
+
end
|
46
|
+
end
|
38
47
|
|
39
48
|
attr_writer :query_string
|
40
49
|
|
@@ -259,26 +259,26 @@ module GraphQL
|
|
259
259
|
# If this isn't lazy, then the block returns eagerly and assigns the result here
|
260
260
|
# If it _is_ lazy, then we write the lazy to the hash, then update it later
|
261
261
|
argument_values[arg_key] = context.schema.after_lazy(coerced_value) do |resolved_coerced_value|
|
262
|
+
owner.validate_directive_argument(self, resolved_coerced_value)
|
263
|
+
prepared_value = begin
|
264
|
+
prepare_value(parent_object, resolved_coerced_value, context: context)
|
265
|
+
rescue StandardError => err
|
266
|
+
context.schema.handle_or_reraise(context, err)
|
267
|
+
end
|
268
|
+
|
262
269
|
if loads && !from_resolver?
|
263
270
|
loaded_value = begin
|
264
|
-
load_and_authorize_value(owner,
|
271
|
+
load_and_authorize_value(owner, prepared_value, context)
|
265
272
|
rescue StandardError => err
|
266
273
|
context.schema.handle_or_reraise(context, err)
|
267
274
|
end
|
268
275
|
end
|
269
276
|
|
270
|
-
maybe_loaded_value = loaded_value ||
|
277
|
+
maybe_loaded_value = loaded_value || prepared_value
|
271
278
|
context.schema.after_lazy(maybe_loaded_value) do |resolved_loaded_value|
|
272
|
-
owner.validate_directive_argument(self, resolved_loaded_value)
|
273
|
-
prepared_value = begin
|
274
|
-
prepare_value(parent_object, resolved_loaded_value, context: context)
|
275
|
-
rescue StandardError => err
|
276
|
-
context.schema.handle_or_reraise(context, err)
|
277
|
-
end
|
278
|
-
|
279
279
|
# TODO code smell to access such a deeply-nested constant in a distant module
|
280
280
|
argument_values[arg_key] = GraphQL::Execution::Interpreter::ArgumentValue.new(
|
281
|
-
value:
|
281
|
+
value: resolved_loaded_value,
|
282
282
|
definition: self,
|
283
283
|
default_used: default_used,
|
284
284
|
)
|
@@ -323,8 +323,14 @@ module GraphQL
|
|
323
323
|
end
|
324
324
|
# Double-check that the located object is actually of this type
|
325
325
|
# (Don't want to allow arbitrary access to objects this way)
|
326
|
-
|
327
|
-
context.schema.after_lazy(
|
326
|
+
maybe_lazy_resolve_type = context.schema.resolve_type(argument.loads, application_object, context)
|
327
|
+
context.schema.after_lazy(maybe_lazy_resolve_type) do |resolve_type_result|
|
328
|
+
if resolve_type_result.is_a?(Array) && resolve_type_result.size == 2
|
329
|
+
application_object_type, application_object = resolve_type_result
|
330
|
+
else
|
331
|
+
application_object_type = resolve_type_result
|
332
|
+
# application_object is already assigned
|
333
|
+
end
|
328
334
|
possible_object_types = context.warden.possible_types(argument.loads)
|
329
335
|
if !possible_object_types.include?(application_object_type)
|
330
336
|
err = GraphQL::LoadApplicationObjectFailedError.new(argument: argument, id: id, object: application_object)
|
data/lib/graphql/schema.rb
CHANGED
@@ -754,13 +754,21 @@ module GraphQL
|
|
754
754
|
# rubocop:disable Lint/DuplicateMethods
|
755
755
|
module ResolveTypeWithType
|
756
756
|
def resolve_type(type, obj, ctx)
|
757
|
-
|
757
|
+
maybe_lazy_resolve_type_result = if type.is_a?(Module) && type.respond_to?(:resolve_type)
|
758
758
|
type.resolve_type(obj, ctx)
|
759
759
|
else
|
760
760
|
super
|
761
761
|
end
|
762
762
|
|
763
|
-
after_lazy(
|
763
|
+
after_lazy(maybe_lazy_resolve_type_result) do |resolve_type_result|
|
764
|
+
if resolve_type_result.is_a?(Array) && resolve_type_result.size == 2
|
765
|
+
resolved_type = resolve_type_result[0]
|
766
|
+
resolved_value = resolve_type_result[1]
|
767
|
+
else
|
768
|
+
resolved_type = resolve_type_result
|
769
|
+
resolved_value = obj
|
770
|
+
end
|
771
|
+
|
764
772
|
if resolved_type.nil? || (resolved_type.is_a?(Module) && resolved_type.respond_to?(:kind))
|
765
773
|
if resolved_value
|
766
774
|
[resolved_type, resolved_value]
|
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.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|