graphql 2.3.16 → 2.3.18

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: eba638ac8e67c3d902cbc181c1236f58ed00b58c17ddb3dfa49a506e37c2e413
4
- data.tar.gz: 2b7912e761ebbfc5188603c90f0ec273ed06d58cf648f2690be483b38760cde5
3
+ metadata.gz: 5e0bed192e241186842ca39b44c83c48f671afc972369ae621e99a35207c8a28
4
+ data.tar.gz: ae7547ce51cda8dbb8ae800248dd33baa85807fe08bfdeff2ca438ee3e00634a
5
5
  SHA512:
6
- metadata.gz: 2eddfe7d8008e1fa918f3e5ab12deab7f85e4edf4d73474f8fd878c321c10f6d711ef7edcdb53ec227852f240feca0fbcd1e18850ec2665ab58ff1af005fee71
7
- data.tar.gz: 0464ae90b5770e507bcffb02ef8b99fbff8da6f521c1704306674aca5bfd96609b0c72a088589f650e64466b8746661a3967d470e325bf4afe8100a68fadafa5
6
+ metadata.gz: dc98ab1793f2331d09f2f768e39fe25de559de7c541d7c6eb1231d2bd81191b5aae965136a496abaeeeaa0306d734fff39a18f802aca9ee1acdfa7a2f48078b9
7
+ data.tar.gz: f27d94dc58836926fed62c5102f264fd4c473ded461888c22f3717da535a33751cfcfbd4a6d060fd3093799368fa88833fbf694b55c396d53a580797dc80800f
@@ -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,19 +116,20 @@ module GraphQL
110
116
  end
111
117
 
112
118
  def determine_field_indent(send_node)
113
- surrounding_node = send_node.parent
114
- if !surrounding_node.is_a?(RuboCop::AST::ClassNode)
115
- surrounding_node = surrounding_node.parent
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
116
123
  end
117
124
 
118
- if !surrounding_node.is_a?(RuboCop::AST::ClassNode)
125
+ if type_defn_node.nil?
119
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."
120
127
  end
121
128
 
122
- surrounding_source = surrounding_node.source
123
- indent_test_idx = send_node.location.expression.begin_pos - surrounding_node.source_range.begin_pos - 1
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
124
131
  field_indent = "".dup
125
- while surrounding_source[indent_test_idx] == " "
132
+ while type_defn_source[indent_test_idx] == " "
126
133
  field_indent << " "
127
134
  indent_test_idx -= 1
128
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
@@ -162,6 +162,7 @@ module GraphQL
162
162
  # re-apply them here
163
163
  mods = trace_modules_for(:default)
164
164
  mods.each { |mod| new_class.include(mod) }
165
+ new_class.include(DefaultTraceClass)
165
166
  trace_mode(:default, new_class)
166
167
  backtrace_class = Class.new(new_class)
167
168
  backtrace_class.include(GraphQL::Backtrace::Trace)
@@ -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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.3.16"
3
+ VERSION = "2.3.18"
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.16
4
+ version: 2.3.18
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-12 00:00:00.000000000 Z
11
+ date: 2024-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -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