graphql 2.3.15 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe9b171f92b1787bd8733bf0fad9843275a95d39905719c5f10694e7999beed9
4
- data.tar.gz: fa6a3502ddf18968eb7f371529225c5982fef12b3f2bee95ffb68dc6bc121382
3
+ metadata.gz: 194930c79609165d98c3ee58c55d557ce5666860dccd4b4718666bf9080178f6
4
+ data.tar.gz: c3bcc14c06fbcd90dcef7e046f96240775f903e479a8d76439cea01cfefe8373
5
5
  SHA512:
6
- metadata.gz: 7cc5ff5de4cc47a3de35255c92410895f381f9bb1a0fd4e0d049e7071a63ed9ab6e57a8d5994447ea8cbf01f7f43de069c3e1ef2804b16385ce783e45186dfcf
7
- data.tar.gz: 8232a0a0dc4722cf85d17cd6a8870ee1208d1b37bc3ba2c15b8b69c5ba05607bcc12b7140b7df7964230087b00a59b5c928d510c6adfe8506ec2d0720d77832c
6
+ metadata.gz: 1a6e461373942ea8ac603a0b7fb6cd6f2153280f9248d9bd0e6f5fae5c1c5e6e9dbf862114a7a518173ce46e5101a3a4e9ea5239d8f3dfcbd60752a6c086ddad
7
+ data.tar.gz: 37e9dcc03c6fd735b6986efa3ea113702f53528bde840341b3d998bbd8a5a35eba11b4e38fded1bedaa8f84dca298e76fbf0d133299fbb4886dbdae36d0a8fe9
@@ -39,7 +39,7 @@ module GraphQL
39
39
  end
40
40
 
41
41
  def inspect
42
- if (name.nil? || parent_class.name.nil?) && parent_class.respond_to?(:mutation) && (mutation = parent_class.mutation)
42
+ if (name.nil? || parent_class&.name.nil?) && parent_class.respond_to?(:mutation) && (mutation = parent_class.mutation)
43
43
  "#{mutation.inspect}::#{parent_class.graphql_name}::InvalidNullError"
44
44
  else
45
45
  super
@@ -29,7 +29,7 @@ module GraphQL
29
29
  def_node_matcher :field_config_with_inline_type_and_block, <<-Pattern
30
30
  (
31
31
  block
32
- (send {nil? _} :field sym ${const array}) ...
32
+ (send {nil? _} :field sym ${const array} ...) ...
33
33
  (args)
34
34
  _
35
35
 
@@ -37,8 +37,8 @@ module GraphQL
37
37
  Pattern
38
38
 
39
39
  def on_block(node)
40
+ ignore_node(node)
40
41
  field_config_with_inline_type_and_block(node) do |type_const|
41
- ignore_node(type_const)
42
42
  type_const_str = get_type_argument_str(node, type_const)
43
43
  if ignore_inline_type_str?(type_const_str)
44
44
  # Do nothing ...
@@ -54,8 +54,8 @@ module GraphQL
54
54
  end
55
55
 
56
56
  def on_send(node)
57
+ return if part_of_ignored_node?(node)
57
58
  field_config_with_inline_type(node) do |type_const|
58
- return if ignored_node?(type_const)
59
59
  type_const_str = get_type_argument_str(node, type_const)
60
60
  if ignore_inline_type_str?(type_const_str)
61
61
  # Do nothing -- not loading from another file
@@ -74,7 +74,13 @@ module GraphQL
74
74
  private
75
75
 
76
76
  def ignore_inline_type_str?(type_str)
77
- BUILT_IN_SCALAR_NAMES.include?(type_str)
77
+ if BUILT_IN_SCALAR_NAMES.include?(type_str)
78
+ true
79
+ elsif (inner_type_str = type_str.sub(/\[([A-Za-z]+)(, null: (true|false))?\]/, '\1')) && BUILT_IN_SCALAR_NAMES.include?(inner_type_str)
80
+ true
81
+ else
82
+ false
83
+ end
78
84
  end
79
85
 
80
86
  def get_type_argument_str(send_node, type_const)
@@ -110,11 +116,20 @@ module GraphQL
110
116
  end
111
117
 
112
118
  def determine_field_indent(send_node)
113
- surrounding_node = send_node.parent.parent
114
- surrounding_source = surrounding_node.source
115
- indent_test_idx = send_node.location.expression.begin_pos - surrounding_node.source_range.begin_pos - 1
119
+ type_defn_node = send_node
120
+
121
+ while (type_defn_node && !(type_defn_node.class_definition? || type_defn_node.module_definition?))
122
+ type_defn_node = type_defn_node.parent
123
+ end
124
+
125
+ if type_defn_node.nil?
126
+ raise "Invariant: Something went wrong in GraphQL-Ruby, couldn't find surrounding class definition for field (#{send_node}).\n\nPlease report this error on GitHub."
127
+ end
128
+
129
+ type_defn_source = type_defn_node.source
130
+ indent_test_idx = send_node.location.expression.begin_pos - type_defn_node.source_range.begin_pos - 1
116
131
  field_indent = "".dup
117
- while surrounding_source[indent_test_idx] == " "
132
+ while type_defn_source[indent_test_idx] == " "
118
133
  field_indent << " "
119
134
  indent_test_idx -= 1
120
135
  if indent_test_idx == 0
@@ -313,7 +313,7 @@ module GraphQL
313
313
  @ast_node = ast_node
314
314
  @method_conflict_warning = method_conflict_warning
315
315
  @fallback_value = fallback_value
316
- @definition_block = nil
316
+ @definition_block = definition_block
317
317
 
318
318
  arguments.each do |name, arg|
319
319
  case arg
@@ -332,14 +332,15 @@ module GraphQL
332
332
  @subscription_scope = subscription_scope
333
333
 
334
334
  @extensions = EMPTY_ARRAY
335
+ @call_after_define = false
335
336
  set_pagination_extensions(connection_extension: connection_extension)
336
337
  # Do this last so we have as much context as possible when initializing them:
337
338
  if extensions.any?
338
- self.extensions(extensions, call_after_define: false)
339
+ self.extensions(extensions)
339
340
  end
340
341
 
341
342
  if resolver_class && resolver_class.extensions.any?
342
- self.extensions(resolver_class.extensions, call_after_define: false)
343
+ self.extensions(resolver_class.extensions)
343
344
  end
344
345
 
345
346
  if directives.any?
@@ -352,10 +353,9 @@ module GraphQL
352
353
  self.validates(validates)
353
354
  end
354
355
 
355
- if block_given?
356
- @definition_block = definition_block
357
- else
356
+ if @definition_block.nil?
358
357
  self.extensions.each(&:after_define_apply)
358
+ @call_after_define = true
359
359
  end
360
360
  end
361
361
 
@@ -372,6 +372,7 @@ module GraphQL
372
372
  instance_eval(&@definition_block)
373
373
  end
374
374
  self.extensions.each(&:after_define_apply)
375
+ @call_after_define = true
375
376
  @definition_block = nil
376
377
  end
377
378
  self
@@ -435,14 +436,14 @@ module GraphQL
435
436
  #
436
437
  # @param extensions [Array<Class, Hash<Class => Hash>>] Add extensions to this field. For hash elements, only the first key/value is used.
437
438
  # @return [Array<GraphQL::Schema::FieldExtension>] extensions to apply to this field
438
- def extensions(new_extensions = nil, call_after_define: !@definition_block)
439
+ def extensions(new_extensions = nil)
439
440
  if new_extensions
440
441
  new_extensions.each do |extension_config|
441
442
  if extension_config.is_a?(Hash)
442
443
  extension_class, options = *extension_config.to_a[0]
443
- self.extension(extension_class, call_after_define: call_after_define, **options)
444
+ self.extension(extension_class, **options)
444
445
  else
445
- self.extension(extension_config, call_after_define: call_after_define)
446
+ self.extension(extension_config)
446
447
  end
447
448
  end
448
449
  end
@@ -460,12 +461,12 @@ module GraphQL
460
461
  # @param extension_class [Class] subclass of {Schema::FieldExtension}
461
462
  # @param options [Hash] if provided, given as `options:` when initializing `extension`.
462
463
  # @return [void]
463
- def extension(extension_class, call_after_define: !@definition_block, **options)
464
+ def extension(extension_class, **options)
464
465
  extension_inst = extension_class.new(field: self, options: options)
465
466
  if @extensions.frozen?
466
467
  @extensions = @extensions.dup
467
468
  end
468
- if call_after_define
469
+ if @call_after_define
469
470
  extension_inst.after_define_apply
470
471
  end
471
472
  @extensions << extension_inst
@@ -166,7 +166,8 @@ module GraphQL
166
166
  #
167
167
  def setup_stream(channel, initial_event)
168
168
  topic = initial_event.topic
169
- channel.stream_from(stream_event_name(initial_event), coder: @action_cable_coder) do |message|
169
+ event_stream = stream_event_name(initial_event)
170
+ channel.stream_from(event_stream, coder: @action_cable_coder) do |message|
170
171
  events_by_fingerprint = @events[topic]
171
172
  object = nil
172
173
  events_by_fingerprint.each do |_fingerprint, events|
@@ -250,6 +250,8 @@ module GraphQL
250
250
  def normalize_arguments(event_name, arg_owner, args, context)
251
251
  case arg_owner
252
252
  when GraphQL::Schema::Field, Class
253
+ return args if args.nil?
254
+
253
255
  if arg_owner.is_a?(Class) && !arg_owner.kind.input_object?
254
256
  # it's a type, but not an input object
255
257
  return args
@@ -302,7 +304,7 @@ module GraphQL
302
304
 
303
305
  normalized_args
304
306
  when GraphQL::Schema::List
305
- args.map { |a| normalize_arguments(event_name, arg_owner.of_type, a, context) }
307
+ args&.map { |a| normalize_arguments(event_name, arg_owner.of_type, a, context) }
306
308
  when GraphQL::Schema::NonNull
307
309
  normalize_arguments(event_name, arg_owner.of_type, args, context)
308
310
  else
@@ -55,6 +55,7 @@ module GraphQL
55
55
  visible_field = dummy_query.types.field(object_type, field_name) # rubocop:disable Development/ContextIsPassedCop
56
56
  if visible_field
57
57
  dummy_query.context.dataloader.run_isolated {
58
+ query_context[:current_field] = visible_field
58
59
  field_args = visible_field.coerce_arguments(graphql_result, arguments, query_context)
59
60
  field_args = schema.sync_lazy(field_args)
60
61
  if visible_field.extras.any?
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.3.15"
3
+ VERSION = "2.3.17"
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: 2.3.15
4
+ version: 2.3.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: 2024-09-10 00:00:00.000000000 Z
11
+ date: 2024-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -168,16 +168,16 @@ dependencies:
168
168
  name: rubocop
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: '1.12'
173
+ version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: '1.12'
180
+ version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: jekyll
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -665,7 +665,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
665
665
  - !ruby/object:Gem::Version
666
666
  version: '0'
667
667
  requirements: []
668
- rubygems_version: 3.3.7
668
+ rubygems_version: 3.5.12
669
669
  signing_key:
670
670
  specification_version: 4
671
671
  summary: A GraphQL language and runtime for Ruby