graphql 2.0.31 → 2.0.32

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1e33fba4f613caa1092e3b95f8020bfbb60b357853a3d3d7f793acd4f673a38
4
- data.tar.gz: 1b5e3157fc10c72fe4b48b815402aa2bca224b90a2d26e441a18f56731b2f238
3
+ metadata.gz: c86c6f3920de2d67a9d8b23a2783ec33f15b70571236db184ca9a9e6b459b80b
4
+ data.tar.gz: 6f4659f46b99da5c6065ba7084b899253958bdb5627b65f469262898cb38205c
5
5
  SHA512:
6
- metadata.gz: 2b91433fccd85d5833fdb3713a7003a8ddb060e57c4086685044cab6403f4efe4d4057b8526ddc312bd5e09c3adb0fcd276bb694aa37dced7374ae774f55f5ca
7
- data.tar.gz: '09314d4624c7364c6e06e14b2fa9289578cf544781038e7087ca6be81eb72a8718295025965df56c1aa59a1fb447eda7cb5d2a89cb17b9d05f433cf76860c65c'
6
+ metadata.gz: 02bf27d69ec35ecdad618ed18a7731fe7d66cd1b5105fcc7625e7b68f534b31e7e5b6f458ba1efe22b5f6e9e6d819cc696e7cdeba6e80bbfa3259691d9ede441
7
+ data.tar.gz: 5b91453bbc8e01a72bcfbe5cef21e7f65704ff1976d945c01291e48667a4a1f36e35f690048ba2a029d5c9f019cfa9c72fa46b2f851b422117de48a4722152ec
@@ -138,6 +138,8 @@ module GraphQL
138
138
  end
139
139
 
140
140
  class << self
141
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
142
+
141
143
  # Add a default `#visit_method` and `#children_method_name` using the class name
142
144
  def inherited(child_class)
143
145
  super
@@ -296,6 +298,7 @@ module GraphQL
296
298
  RUBY
297
299
  end
298
300
  end
301
+ # rubocop:enable Development/NoEvalCop
299
302
  end
300
303
  end
301
304
 
@@ -76,67 +76,6 @@ module GraphQL
76
76
  end
77
77
  end
78
78
 
79
- # We don't use `alias` here because it breaks `super`
80
- def self.make_visit_methods(ast_node_class)
81
- node_method = ast_node_class.visit_method
82
- children_of_type = ast_node_class.children_of_type
83
- child_visit_method = :"#{node_method}_children"
84
-
85
- class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
86
- # The default implementation for visiting an AST node.
87
- # It doesn't _do_ anything, but it continues to visiting the node's children.
88
- # To customize this hook, override one of its make_visit_methods (or the base method?)
89
- # in your subclasses.
90
- #
91
- # For compatibility, it calls hook procs, too.
92
- # @param node [GraphQL::Language::Nodes::AbstractNode] the node being visited
93
- # @param parent [GraphQL::Language::Nodes::AbstractNode, nil] the previously-visited node, or `nil` if this is the root node.
94
- # @return [Array, nil] If there were modifications, it returns an array of new nodes, otherwise, it returns `nil`.
95
- def #{node_method}(node, parent)
96
- if node.equal?(DELETE_NODE)
97
- # This might be passed to `super(DELETE_NODE, ...)`
98
- # by a user hook, don't want to keep visiting in that case.
99
- [node, parent]
100
- else
101
- # Run hooks if there are any
102
- new_node = node
103
- no_hooks = !@visitors.key?(node.class)
104
- if no_hooks || begin_visit(new_node, parent)
105
- #{
106
- if method_defined?(child_visit_method)
107
- "new_node = #{child_visit_method}(new_node)"
108
- elsif children_of_type
109
- children_of_type.map do |child_accessor, child_class|
110
- "node.#{child_accessor}.each do |child_node|
111
- new_child_and_node = #{child_class.visit_method}_with_modifications(child_node, new_node)
112
- # Reassign `node` in case the child hook makes a modification
113
- if new_child_and_node.is_a?(Array)
114
- new_node = new_child_and_node[1]
115
- end
116
- end"
117
- end.join("\n")
118
- else
119
- ""
120
- end
121
- }
122
- end
123
- end_visit(new_node, parent) unless no_hooks
124
-
125
- if new_node.equal?(node)
126
- [node, parent]
127
- else
128
- [new_node, parent]
129
- end
130
- end
131
- end
132
-
133
- def #{node_method}_with_modifications(node, parent)
134
- new_node_and_new_parent = #{node_method}(node, parent)
135
- apply_modifications(node, parent, new_node_and_new_parent)
136
- end
137
- RUBY
138
- end
139
-
140
79
  def on_document_children(document_node)
141
80
  new_node = document_node
142
81
  document_node.children.each do |child_node|
@@ -237,6 +176,68 @@ module GraphQL
237
176
  new_node
238
177
  end
239
178
 
179
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
180
+
181
+ def self.make_visit_methods(ast_node_class)
182
+ node_method = ast_node_class.visit_method
183
+ children_of_type = ast_node_class.children_of_type
184
+ child_visit_method = :"#{node_method}_children"
185
+
186
+ class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
187
+ # The default implementation for visiting an AST node.
188
+ # It doesn't _do_ anything, but it continues to visiting the node's children.
189
+ # To customize this hook, override one of its make_visit_methods (or the base method?)
190
+ # in your subclasses.
191
+ #
192
+ # For compatibility, it calls hook procs, too.
193
+ # @param node [GraphQL::Language::Nodes::AbstractNode] the node being visited
194
+ # @param parent [GraphQL::Language::Nodes::AbstractNode, nil] the previously-visited node, or `nil` if this is the root node.
195
+ # @return [Array, nil] If there were modifications, it returns an array of new nodes, otherwise, it returns `nil`.
196
+ def #{node_method}(node, parent)
197
+ if node.equal?(DELETE_NODE)
198
+ # This might be passed to `super(DELETE_NODE, ...)`
199
+ # by a user hook, don't want to keep visiting in that case.
200
+ [node, parent]
201
+ else
202
+ # Run hooks if there are any
203
+ new_node = node
204
+ no_hooks = !@visitors.key?(node.class)
205
+ if no_hooks || begin_visit(new_node, parent)
206
+ #{
207
+ if method_defined?(child_visit_method)
208
+ "new_node = #{child_visit_method}(new_node)"
209
+ elsif children_of_type
210
+ children_of_type.map do |child_accessor, child_class|
211
+ "node.#{child_accessor}.each do |child_node|
212
+ new_child_and_node = #{child_class.visit_method}_with_modifications(child_node, new_node)
213
+ # Reassign `node` in case the child hook makes a modification
214
+ if new_child_and_node.is_a?(Array)
215
+ new_node = new_child_and_node[1]
216
+ end
217
+ end"
218
+ end.join("\n")
219
+ else
220
+ ""
221
+ end
222
+ }
223
+ end
224
+ end_visit(new_node, parent) unless no_hooks
225
+ if new_node.equal?(node)
226
+ [node, parent]
227
+ else
228
+ [new_node, parent]
229
+ end
230
+ end
231
+ end
232
+ def #{node_method}_with_modifications(node, parent)
233
+ new_node_and_new_parent = #{node_method}(node, parent)
234
+ apply_modifications(node, parent, new_node_and_new_parent)
235
+ end
236
+ RUBY
237
+ end
238
+
239
+
240
+
240
241
  [
241
242
  Language::Nodes::Argument,
242
243
  Language::Nodes::Directive,
@@ -277,6 +278,8 @@ module GraphQL
277
278
  make_visit_methods(ast_node_class)
278
279
  end
279
280
 
281
+ # rubocop:enable Development/NoEvalCop
282
+
280
283
  private
281
284
 
282
285
  def apply_modifications(node, parent, new_node_and_new_parent)
@@ -53,6 +53,7 @@ module GraphQL
53
53
  def initialize(arg_name = nil, type_expr = nil, desc = nil, required: true, type: nil, name: nil, loads: nil, description: nil, ast_node: nil, default_value: NOT_CONFIGURED, as: nil, from_resolver: false, camelize: true, prepare: nil, owner:, validates: nil, directives: nil, deprecation_reason: nil, replace_null_with_default: false, &definition_block)
54
54
  arg_name ||= name
55
55
  @name = -(camelize ? Member::BuildType.camelize(arg_name.to_s) : arg_name.to_s)
56
+ NameValidator.validate!(@name)
56
57
  @type_expr = type_expr || type
57
58
  @description = desc || description
58
59
  @null = required != true
@@ -88,11 +89,8 @@ module GraphQL
88
89
  end
89
90
 
90
91
  if definition_block
91
- if definition_block.arity == 1
92
- instance_exec(self, &definition_block)
93
- else
94
- instance_eval(&definition_block)
95
- end
92
+ # `self` will still be self, it will also be the first argument to the block:
93
+ instance_exec(self, &definition_block)
96
94
  end
97
95
  end
98
96
 
@@ -453,17 +453,18 @@ module GraphQL
453
453
 
454
454
  # Don't do this for interfaces
455
455
  if default_resolve
456
- owner.class_eval <<-RUBY, __FILE__, __LINE__
457
- # frozen_string_literal: true
458
- def #{resolve_method_name}(**args)
459
- field_instance = self.class.get_field("#{field_definition.name}")
460
- context.schema.definition_default_resolve.call(self.class, field_instance, object, args, context)
461
- end
462
- RUBY
456
+ define_field_resolve_method(owner, resolve_method_name, field_definition.name)
463
457
  end
464
458
  end
465
459
  end
466
460
 
461
+ def define_field_resolve_method(owner, method_name, field_name)
462
+ owner.define_method(method_name) { |**args|
463
+ field_instance = self.class.get_field(field_name)
464
+ context.schema.definition_default_resolve.call(self.class, field_instance, object, args, context)
465
+ }
466
+ end
467
+
467
468
  def build_resolve_type(lookup_hash, directives, missing_type_handler)
468
469
  resolve_type_proc = nil
469
470
  resolve_type_proc = ->(ast_node) {
@@ -99,7 +99,7 @@ module GraphQL
99
99
 
100
100
  def inherited(subclass)
101
101
  super
102
- subclass.class_eval do
102
+ subclass.class_exec do
103
103
  @default_graphql_name ||= nil
104
104
  end
105
105
  end
@@ -47,7 +47,7 @@ module GraphQL
47
47
  end
48
48
 
49
49
  if block_given?
50
- instance_eval(&block)
50
+ instance_exec(self, &block)
51
51
  end
52
52
  end
53
53
 
@@ -233,7 +233,7 @@ module GraphQL
233
233
 
234
234
  @underscored_name = -Member::BuildType.underscore(name_s)
235
235
  @name = -(camelize ? Member::BuildType.camelize(name_s) : name_s)
236
-
236
+ NameValidator.validate!(@name)
237
237
  @description = description
238
238
  @type = @owner_type = @own_validators = @own_directives = @own_arguments = @arguments_statically_coercible = nil # these will be prepared later if necessary
239
239
 
@@ -131,12 +131,7 @@ module GraphQL
131
131
  end
132
132
  end
133
133
  # Add a method access
134
- method_name = argument_defn.keyword
135
- class_eval <<-RUBY, __FILE__, __LINE__
136
- def #{method_name}
137
- self[#{method_name.inspect}]
138
- end
139
- RUBY
134
+ define_accessor_method(argument_defn.keyword)
140
135
  argument_defn
141
136
  end
142
137
 
@@ -242,6 +237,13 @@ module GraphQL
242
237
 
243
238
  result
244
239
  end
240
+
241
+ private
242
+
243
+ def define_accessor_method(method_name)
244
+ define_method(method_name) { self[method_name] }
245
+ alias_method(method_name, method_name)
246
+ end
245
247
  end
246
248
 
247
249
  private
@@ -6,7 +6,7 @@ module GraphQL
6
6
  module HasDirectives
7
7
  def self.extended(child_cls)
8
8
  super
9
- child_cls.module_eval { self.own_directives = nil }
9
+ child_cls.module_exec { self.own_directives = nil }
10
10
  end
11
11
 
12
12
  def inherited(child_cls)
@@ -180,7 +180,7 @@ module GraphQL
180
180
 
181
181
  def inherited(subclass)
182
182
  super
183
- subclass.class_eval do
183
+ subclass.class_exec do
184
184
  @own_fields ||= nil
185
185
  @field_class ||= nil
186
186
  end
@@ -119,7 +119,7 @@ module GraphQL
119
119
 
120
120
  def inherited(subclass)
121
121
  super
122
- subclass.class_eval do
122
+ subclass.class_exec do
123
123
  @own_interface_type_memberships ||= nil
124
124
  end
125
125
  end
@@ -43,7 +43,7 @@ module GraphQL
43
43
  private
44
44
 
45
45
  def inherited(subclass)
46
- subclass.class_eval do
46
+ subclass.class_exec do
47
47
  @to_non_null_type ||= nil
48
48
  @to_list_type ||= nil
49
49
  end
@@ -28,6 +28,8 @@ module GraphQL
28
28
  Gem::Version.new('1.0.0')
29
29
  end
30
30
 
31
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
32
+
31
33
  [
32
34
  'lex',
33
35
  'parse',
@@ -55,6 +57,8 @@ module GraphQL
55
57
  RUBY
56
58
  end
57
59
 
60
+ # rubocop:enable Development/NoEvalCop
61
+
58
62
  def execute_field(query:, field:, ast_node:, arguments:, object:)
59
63
  return_type = field.type.unwrap
60
64
  trace_field = if return_type.kind.scalar? || return_type.kind.enum?
@@ -13,6 +13,8 @@ module GraphQL
13
13
  super
14
14
  end
15
15
 
16
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
17
+
16
18
  {
17
19
  "lex" => "lex.graphql",
18
20
  "parse" => "parse.graphql",
@@ -43,6 +45,8 @@ module GraphQL
43
45
  RUBY
44
46
  end
45
47
 
48
+ # rubocop:enable Development/NoEvalCop
49
+
46
50
  def platform_execute_field(platform_key)
47
51
  Appsignal.instrument(platform_key) do
48
52
  yield
@@ -20,6 +20,8 @@ module GraphQL
20
20
  super
21
21
  end
22
22
 
23
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
24
+
23
25
  {
24
26
  'lex' => 'lex.graphql',
25
27
  'parse' => 'parse.graphql',
@@ -69,6 +71,8 @@ module GraphQL
69
71
  RUBY
70
72
  end
71
73
 
74
+ # rubocop:enable Development/NoEvalCop
75
+
72
76
  def execute_field_span(span_key, query, field, ast_node, arguments, object)
73
77
  return_type = field.type.unwrap
74
78
  trace_field = if return_type.kind.scalar? || return_type.kind.enum?
@@ -16,6 +16,8 @@ module GraphQL
16
16
  super
17
17
  end
18
18
 
19
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
20
+
19
21
  {
20
22
  "lex" => "lex.graphql",
21
23
  "parse" => "parse.graphql",
@@ -39,6 +41,8 @@ module GraphQL
39
41
  RUBY
40
42
  end
41
43
 
44
+ # rubocop:enable Development/NoEvalCop
45
+
42
46
  include PlatformTrace
43
47
  end
44
48
  end
@@ -39,6 +39,9 @@ module GraphQL
39
39
  include(BaseKeyCache)
40
40
  }
41
41
  child_class.const_set(:KeyCache, key_methods_class)
42
+
43
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
44
+
42
45
  [:execute_field, :execute_field_lazy].each do |field_trace_method|
43
46
  if !child_class.method_defined?(field_trace_method)
44
47
  child_class.module_eval <<-RUBY, __FILE__, __LINE__
@@ -91,6 +94,8 @@ module GraphQL
91
94
  end
92
95
  RUBY
93
96
  end
97
+
98
+ # rubocop:enable Development/NoEvalCop
94
99
  end
95
100
  end
96
101
 
@@ -13,6 +13,8 @@ module GraphQL
13
13
  super(**rest)
14
14
  end
15
15
 
16
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
17
+
16
18
  {
17
19
  'lex' => "graphql.lex",
18
20
  'parse' => "graphql.parse",
@@ -30,6 +32,8 @@ module GraphQL
30
32
  RUBY
31
33
  end
32
34
 
35
+ # rubocop:enable Development/NoEvalCop
36
+
33
37
  def platform_execute_field(platform_key, &block)
34
38
  instrument_execution(platform_key, "execute_field", &block)
35
39
  end
@@ -16,6 +16,8 @@ module GraphQL
16
16
  super
17
17
  end
18
18
 
19
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
20
+
19
21
  {
20
22
  "lex" => "lex.graphql",
21
23
  "parse" => "parse.graphql",
@@ -45,6 +47,7 @@ module GraphQL
45
47
  end
46
48
  RUBY
47
49
  end
50
+ # rubocop:enable Development/NoEvalCop
48
51
 
49
52
  def platform_execute_field(platform_key, &block)
50
53
  self.class.instrument("GraphQL", platform_key, INSTRUMENT_OPTS, &block)
@@ -11,6 +11,8 @@ module GraphQL
11
11
  super(**rest)
12
12
  end
13
13
 
14
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
15
+
14
16
  {
15
17
  'lex' => "graphql.lex",
16
18
  'parse' => "graphql.parse",
@@ -30,6 +32,8 @@ module GraphQL
30
32
  RUBY
31
33
  end
32
34
 
35
+ # rubocop:enable Development/NoEvalCop
36
+
33
37
  def platform_execute_field(platform_key, &block)
34
38
  @statsd.time(platform_key, &block)
35
39
  end
@@ -13,7 +13,7 @@ module GraphQL
13
13
  child_class.node_nullable(true)
14
14
  child_class.edges_nullable(true)
15
15
  child_class.edge_nullable(true)
16
- child_class.module_eval {
16
+ child_class.module_exec {
17
17
  self.edge_type = nil
18
18
  self.node_type = nil
19
19
  self.edge_class = nil
@@ -8,7 +8,7 @@ module GraphQL
8
8
  child_class.description("An edge in a connection.")
9
9
  child_class.field(:cursor, String, null: false, description: "A cursor for use in pagination.")
10
10
  child_class.extend(ClassMethods)
11
- child_class.class_eval { self.node_type = nil }
11
+ child_class.class_exec { self.node_type = nil }
12
12
  child_class.node_nullable(true)
13
13
  end
14
14
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.0.31"
3
+ VERSION = "2.0.32"
4
4
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.31
4
+ version: 2.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-06-13 00:00:00.000000000 Z
10
+ date: 2025-03-12 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: base64
@@ -622,7 +621,6 @@ metadata:
622
621
  source_code_uri: https://github.com/rmosolgo/graphql-ruby
623
622
  bug_tracker_uri: https://github.com/rmosolgo/graphql-ruby/issues
624
623
  mailing_list_uri: https://tinyletter.com/graphql-ruby
625
- post_install_message:
626
624
  rdoc_options: []
627
625
  require_paths:
628
626
  - lib
@@ -637,8 +635,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
637
635
  - !ruby/object:Gem::Version
638
636
  version: '0'
639
637
  requirements: []
640
- rubygems_version: 3.5.3
641
- signing_key:
638
+ rubygems_version: 3.6.3
642
639
  specification_version: 4
643
640
  summary: A GraphQL language and runtime for Ruby
644
641
  test_files: []