graphql 1.12.9 → 1.12.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcd53f90295f4a4444841bee25b0329ba993ea2ae3d10bb9ba807f262b9354ca
4
- data.tar.gz: af7807ae411d7f50252758b64c2248fc3c640cc2930c22c0740bae25d567e7ef
3
+ metadata.gz: 9d314c3a4dbbf6bded442bea6c2fcdd68b0cd7730ebb5e807d3677ffdc838268
4
+ data.tar.gz: 60a24771181bb8a479f768a4b17f3a474ff9bbc339027b94e18bf92554df296c
5
5
  SHA512:
6
- metadata.gz: 770c7bde4c17619f645d77829bb9ca78bed5f944a7609a31095d9e8e859adbf0728988a640ad98a3a10fbccc73f658a0906296d1d6bed5f0f6d77b53a9bf9c79
7
- data.tar.gz: 9fee4b7cb3e63c07a702462c1b6ebc0a0bd2d1342a4d22803839b63a03d8a910ebd6189a748695ba75e2732e1af30e9a6b9587d72be602eee6b1db43822bb779
6
+ metadata.gz: 25f941249c01ce4dcfe3522dfc7b045b6f2bd3888e1f21b2e25a3ae5de74f0de5f9721c998d6ddd33eb681339c3e883edcdc9d76a196c148b688a1264b1761fa
7
+ data.tar.gz: 91bde8d0102ae6874511656b6e11140b511aa1813d19b70b91a168cf58cbfc95eb83a6244137fc06abeae19f15694ca005c94c6e728085d0b8be3ad3bb964ebc
@@ -52,22 +52,25 @@ module GraphQL
52
52
  set_all_interpreter_context(query.root_value, nil, nil, path)
53
53
  object_proxy = authorized_new(root_type, query.root_value, context)
54
54
  object_proxy = schema.sync_lazy(object_proxy)
55
+
55
56
  if object_proxy.nil?
56
57
  # Root .authorized? returned false.
57
58
  write_in_response(path, nil)
58
59
  else
59
- gathered_selections = gather_selections(object_proxy, root_type, root_operation.selections)
60
- # Make the first fiber which will begin execution
61
- @dataloader.append_job {
62
- evaluate_selections(
63
- path,
64
- context.scoped_context,
65
- object_proxy,
66
- root_type,
67
- root_op_type == "mutation",
68
- gathered_selections,
69
- )
70
- }
60
+ resolve_with_directives(object_proxy, root_operation) do # execute query level directives
61
+ gathered_selections = gather_selections(object_proxy, root_type, root_operation.selections)
62
+ # Make the first fiber which will begin execution
63
+ @dataloader.append_job {
64
+ evaluate_selections(
65
+ path,
66
+ context.scoped_context,
67
+ object_proxy,
68
+ root_type,
69
+ root_op_type == "mutation",
70
+ gathered_selections,
71
+ )
72
+ }
73
+ end
71
74
  end
72
75
  delete_interpreter_context(:current_path)
73
76
  delete_interpreter_context(:current_field)
@@ -9,10 +9,16 @@ module GraphQL
9
9
  def visible_type?(t); true; end
10
10
  end
11
11
 
12
+ class NullQuery
13
+ def with_error_handling
14
+ yield
15
+ end
16
+ end
17
+
12
18
  attr_reader :schema, :query, :warden, :dataloader
13
19
 
14
20
  def initialize
15
- @query = nil
21
+ @query = NullQuery.new
16
22
  @dataloader = GraphQL::Dataloader::NullDataloader.new
17
23
  @schema = GraphQL::Schema.new
18
24
  @warden = NullWarden.new(
@@ -98,6 +98,9 @@ module GraphQL
98
98
  result = schema.public_send(method_name, only: @only, except: @except, context: context)
99
99
  dir = File.dirname(file)
100
100
  FileUtils.mkdir_p(dir)
101
+ if !result.end_with?("\n")
102
+ result += "\n"
103
+ end
101
104
  File.write(file, result)
102
105
  end
103
106
 
@@ -266,7 +266,9 @@ module GraphQL
266
266
  loaded_values = coerced_value.map { |val| owner.load_application_object(self, loads, val, context) }
267
267
  context.schema.after_any_lazies(loaded_values) { |result| result }
268
268
  else
269
- owner.load_application_object(self, loads, coerced_value, context)
269
+ context.query.with_error_handling do
270
+ owner.load_application_object(self, loads, coerced_value, context)
271
+ end
270
272
  end
271
273
  end
272
274
 
@@ -169,6 +169,12 @@ module GraphQL
169
169
  def build_fields(type_defn, fields, type_resolver)
170
170
  loader = self
171
171
  fields.each do |field_hash|
172
+ unwrapped_field_hash = field_hash
173
+ while (of_type = unwrapped_field_hash["ofType"])
174
+ unwrapped_field_hash = of_type
175
+ end
176
+ type_name = unwrapped_field_hash["name"]
177
+
172
178
  type_defn.field(
173
179
  field_hash["name"],
174
180
  type: type_resolver.call(field_hash["type"]),
@@ -176,6 +182,8 @@ module GraphQL
176
182
  deprecation_reason: field_hash["deprecationReason"],
177
183
  null: true,
178
184
  camelize: false,
185
+ connection_extension: nil,
186
+ connection: type_name.end_with?("Connection"),
179
187
  ) do
180
188
  if field_hash["args"].any?
181
189
  loader.build_arguments(self, field_hash["args"], type_resolver)
@@ -333,30 +333,32 @@ module GraphQL
333
333
  arg_defn = super(*args, from_resolver: true, **kwargs)
334
334
  own_arguments_loads_as_type[arg_defn.keyword] = loads if loads
335
335
 
336
- if loads && arg_defn.type.list?
337
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
338
- def load_#{arg_defn.keyword}(values)
339
- argument = @arguments_by_keyword[:#{arg_defn.keyword}]
340
- lookup_as_type = @arguments_loads_as_type[:#{arg_defn.keyword}]
341
- context.schema.after_lazy(values) do |values2|
342
- GraphQL::Execution::Lazy.all(values2.map { |value| load_application_object(argument, lookup_as_type, value, context) })
336
+ if !method_defined?(:"load_#{arg_defn.keyword}")
337
+ if loads && arg_defn.type.list?
338
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
339
+ def load_#{arg_defn.keyword}(values)
340
+ argument = @arguments_by_keyword[:#{arg_defn.keyword}]
341
+ lookup_as_type = @arguments_loads_as_type[:#{arg_defn.keyword}]
342
+ context.schema.after_lazy(values) do |values2|
343
+ GraphQL::Execution::Lazy.all(values2.map { |value| load_application_object(argument, lookup_as_type, value, context) })
344
+ end
343
345
  end
346
+ RUBY
347
+ elsif loads
348
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
349
+ def load_#{arg_defn.keyword}(value)
350
+ argument = @arguments_by_keyword[:#{arg_defn.keyword}]
351
+ lookup_as_type = @arguments_loads_as_type[:#{arg_defn.keyword}]
352
+ load_application_object(argument, lookup_as_type, value, context)
353
+ end
354
+ RUBY
355
+ else
356
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
357
+ def load_#{arg_defn.keyword}(value)
358
+ value
359
+ end
360
+ RUBY
344
361
  end
345
- RUBY
346
- elsif loads
347
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
348
- def load_#{arg_defn.keyword}(value)
349
- argument = @arguments_by_keyword[:#{arg_defn.keyword}]
350
- lookup_as_type = @arguments_loads_as_type[:#{arg_defn.keyword}]
351
- load_application_object(argument, lookup_as_type, value, context)
352
- end
353
- RUBY
354
- else
355
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
356
- def load_#{arg_defn.keyword}(value)
357
- value
358
- end
359
- RUBY
360
362
  end
361
363
 
362
364
  arg_defn
@@ -44,7 +44,9 @@ module GraphQL
44
44
  def validate_non_null_input(value, ctx)
45
45
  result = Query::InputValidationResult.new
46
46
  coerced_result = begin
47
- coerce_input(value, ctx)
47
+ ctx.query.with_error_handling do
48
+ coerce_input(value, ctx)
49
+ end
48
50
  rescue GraphQL::CoercionError => err
49
51
  err
50
52
  end
@@ -23,7 +23,7 @@ module GraphQL
23
23
  defn = if arg_defn && arg_defn.type.unwrap.kind.input_object?
24
24
  arg_defn.type.unwrap
25
25
  else
26
- context.field_definition
26
+ context.directive_definition || context.field_definition
27
27
  end
28
28
 
29
29
  parent_type = context.warden.get_argument(defn, parent_name(parent, defn))
@@ -73,6 +73,11 @@ module GraphQL
73
73
  irep: irep,
74
74
  }
75
75
  end
76
+ rescue GraphQL::ExecutionError => e
77
+ {
78
+ errors: [e],
79
+ irep: nil,
80
+ }
76
81
  end
77
82
 
78
83
  # Invoked when static validation times out.
@@ -55,7 +55,14 @@ module GraphQL
55
55
  # @return [Object] An object that load Global::Identification recursive
56
56
  def load_value(value)
57
57
  if value.is_a?(Array)
58
- value.map{|item| load_value(item)}
58
+ is_gids = (v1 = value[0]).is_a?(Hash) && v1.size == 1 && v1[GLOBALID_KEY]
59
+ if is_gids
60
+ # Assume it's an array of global IDs
61
+ ids = value.map { |v| v[GLOBALID_KEY] }
62
+ GlobalID::Locator.locate_many(ids)
63
+ else
64
+ value.map { |item| load_value(item) }
65
+ end
59
66
  elsif value.is_a?(Hash)
60
67
  if value.size == 1
61
68
  case value.keys.first # there's only 1 key
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.12.9"
3
+ VERSION = "1.12.10"
4
4
  end
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.12.9
4
+ version: 1.12.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-07 00:00:00.000000000 Z
11
+ date: 2021-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -699,7 +699,7 @@ metadata:
699
699
  source_code_uri: https://github.com/rmosolgo/graphql-ruby
700
700
  bug_tracker_uri: https://github.com/rmosolgo/graphql-ruby/issues
701
701
  mailing_list_uri: https://tinyletter.com/graphql-ruby
702
- post_install_message:
702
+ post_install_message:
703
703
  rdoc_options: []
704
704
  require_paths:
705
705
  - lib
@@ -714,8 +714,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
714
714
  - !ruby/object:Gem::Version
715
715
  version: '0'
716
716
  requirements: []
717
- rubygems_version: 3.1.4
718
- signing_key:
717
+ rubygems_version: 3.2.15
718
+ signing_key:
719
719
  specification_version: 4
720
720
  summary: A GraphQL language and runtime for Ruby
721
721
  test_files: []