graphql 2.1.13 → 2.1.15

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: 4266d452932b792f220bf55dd6a5a54516939c3b6ec59f84a5202382aa1b3489
4
- data.tar.gz: 61e5c45e2b4206b646a72d8968152ef086c956aeaa97f4327a888dc5a91dbea0
3
+ metadata.gz: 0da36aaaf7f059cae47d9120a490c5fd05ee96999bb7a401f1c4cf711d55bebe
4
+ data.tar.gz: 50409b87b5716a3ccdabe69906fe57564c593e4ac9de038f178407877783e762
5
5
  SHA512:
6
- metadata.gz: 19b106f49cad299accab3831f302022b39f38cbaf527f32a33d4dc03a2fe666503d359dd5fb432fecbc2901f74c80b4fa053c3614ee2936404ce99ff7fcaca87
7
- data.tar.gz: b414379bced7f488990405411ee2b7450ab4c7bf349624392901aa057cb46884b5b2fd5dea1f2716de5f7d4783db6644ad03a3c747162f0b87137b75a4f1bc90
6
+ metadata.gz: d16b0cae17f595f29d9dbdf02fbbf74f42654fc766583f896388fc73f7742c16edb9d32aa23706254388629a41cbc30c39e30a867cd5b552791e75f356f5c076
7
+ data.tar.gz: 19b7ec6d5aa1eba7dd9cb340035b5bfa472e631683554bedbc5593b2a3a68bb3a3847cd5672c6a0f6e829029f42c0f47a3e926ec4dba01969b3ce9cea047814b
@@ -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
 
@@ -22,39 +22,6 @@ module GraphQL
22
22
  end
23
23
  end
24
24
 
25
- # We don't use `alias` here because it breaks `super`
26
- def self.make_visit_methods(ast_node_class)
27
- node_method = ast_node_class.visit_method
28
- children_of_type = ast_node_class.children_of_type
29
- child_visit_method = :"#{node_method}_children"
30
-
31
- class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
32
- # The default implementation for visiting an AST node.
33
- # It doesn't _do_ anything, but it continues to visiting the node's children.
34
- # To customize this hook, override one of its make_visit_methods (or the base method?)
35
- # in your subclasses.
36
- #
37
- # @param node [GraphQL::Language::Nodes::AbstractNode] the node being visited
38
- # @param parent [GraphQL::Language::Nodes::AbstractNode, nil] the previously-visited node, or `nil` if this is the root node.
39
- # @return [void]
40
- def #{node_method}(node, parent)
41
- #{
42
- if method_defined?(child_visit_method)
43
- "#{child_visit_method}(node)"
44
- elsif children_of_type
45
- children_of_type.map do |child_accessor, child_class|
46
- "node.#{child_accessor}.each do |child_node|
47
- #{child_class.visit_method}(child_node, node)
48
- end"
49
- end.join("\n")
50
- else
51
- ""
52
- end
53
- }
54
- end
55
- RUBY
56
- end
57
-
58
25
  def on_document_children(document_node)
59
26
  document_node.children.each do |child_node|
60
27
  visit_method = child_node.visit_method
@@ -123,6 +90,41 @@ module GraphQL
123
90
  end
124
91
  end
125
92
 
93
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
94
+
95
+ # We don't use `alias` here because it breaks `super`
96
+ def self.make_visit_methods(ast_node_class)
97
+ node_method = ast_node_class.visit_method
98
+ children_of_type = ast_node_class.children_of_type
99
+ child_visit_method = :"#{node_method}_children"
100
+
101
+ class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
102
+ # The default implementation for visiting an AST node.
103
+ # It doesn't _do_ anything, but it continues to visiting the node's children.
104
+ # To customize this hook, override one of its make_visit_methods (or the base method?)
105
+ # in your subclasses.
106
+ #
107
+ # @param node [GraphQL::Language::Nodes::AbstractNode] the node being visited
108
+ # @param parent [GraphQL::Language::Nodes::AbstractNode, nil] the previously-visited node, or `nil` if this is the root node.
109
+ # @return [void]
110
+ def #{node_method}(node, parent)
111
+ #{
112
+ if method_defined?(child_visit_method)
113
+ "#{child_visit_method}(node)"
114
+ elsif children_of_type
115
+ children_of_type.map do |child_accessor, child_class|
116
+ "node.#{child_accessor}.each do |child_node|
117
+ #{child_class.visit_method}(child_node, node)
118
+ end"
119
+ end.join("\n")
120
+ else
121
+ ""
122
+ end
123
+ }
124
+ end
125
+ RUBY
126
+ end
127
+
126
128
  [
127
129
  Language::Nodes::Argument,
128
130
  Language::Nodes::Directive,
@@ -162,6 +164,8 @@ module GraphQL
162
164
  ].each do |ast_node_class|
163
165
  make_visit_methods(ast_node_class)
164
166
  end
167
+
168
+ # rubocop:disable Development/NoEvalCop
165
169
  end
166
170
  end
167
171
  end
@@ -61,61 +61,6 @@ module GraphQL
61
61
  end
62
62
  end
63
63
 
64
- # We don't use `alias` here because it breaks `super`
65
- def self.make_visit_methods(ast_node_class)
66
- node_method = ast_node_class.visit_method
67
- children_of_type = ast_node_class.children_of_type
68
- child_visit_method = :"#{node_method}_children"
69
-
70
- class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
71
- # The default implementation for visiting an AST node.
72
- # It doesn't _do_ anything, but it continues to visiting the node's children.
73
- # To customize this hook, override one of its make_visit_methods (or the base method?)
74
- # in your subclasses.
75
- #
76
- # @param node [GraphQL::Language::Nodes::AbstractNode] the node being visited
77
- # @param parent [GraphQL::Language::Nodes::AbstractNode, nil] the previously-visited node, or `nil` if this is the root node.
78
- # @return [Array, nil] If there were modifications, it returns an array of new nodes, otherwise, it returns `nil`.
79
- def #{node_method}(node, parent)
80
- if node.equal?(DELETE_NODE)
81
- # This might be passed to `super(DELETE_NODE, ...)`
82
- # by a user hook, don't want to keep visiting in that case.
83
- [node, parent]
84
- else
85
- new_node = node
86
- #{
87
- if method_defined?(child_visit_method)
88
- "new_node = #{child_visit_method}(new_node)"
89
- elsif children_of_type
90
- children_of_type.map do |child_accessor, child_class|
91
- "node.#{child_accessor}.each do |child_node|
92
- new_child_and_node = #{child_class.visit_method}_with_modifications(child_node, new_node)
93
- # Reassign `node` in case the child hook makes a modification
94
- if new_child_and_node.is_a?(Array)
95
- new_node = new_child_and_node[1]
96
- end
97
- end"
98
- end.join("\n")
99
- else
100
- ""
101
- end
102
- }
103
-
104
- if new_node.equal?(node)
105
- [node, parent]
106
- else
107
- [new_node, parent]
108
- end
109
- end
110
- end
111
-
112
- def #{node_method}_with_modifications(node, parent)
113
- new_node_and_new_parent = #{node_method}(node, parent)
114
- apply_modifications(node, parent, new_node_and_new_parent)
115
- end
116
- RUBY
117
- end
118
-
119
64
  def on_document_children(document_node)
120
65
  new_node = document_node
121
66
  document_node.children.each do |child_node|
@@ -216,6 +161,63 @@ module GraphQL
216
161
  new_node
217
162
  end
218
163
 
164
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
165
+
166
+ # We don't use `alias` here because it breaks `super`
167
+ def self.make_visit_methods(ast_node_class)
168
+ node_method = ast_node_class.visit_method
169
+ children_of_type = ast_node_class.children_of_type
170
+ child_visit_method = :"#{node_method}_children"
171
+
172
+ class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
173
+ # The default implementation for visiting an AST node.
174
+ # It doesn't _do_ anything, but it continues to visiting the node's children.
175
+ # To customize this hook, override one of its make_visit_methods (or the base method?)
176
+ # in your subclasses.
177
+ #
178
+ # @param node [GraphQL::Language::Nodes::AbstractNode] the node being visited
179
+ # @param parent [GraphQL::Language::Nodes::AbstractNode, nil] the previously-visited node, or `nil` if this is the root node.
180
+ # @return [Array, nil] If there were modifications, it returns an array of new nodes, otherwise, it returns `nil`.
181
+ def #{node_method}(node, parent)
182
+ if node.equal?(DELETE_NODE)
183
+ # This might be passed to `super(DELETE_NODE, ...)`
184
+ # by a user hook, don't want to keep visiting in that case.
185
+ [node, parent]
186
+ else
187
+ new_node = node
188
+ #{
189
+ if method_defined?(child_visit_method)
190
+ "new_node = #{child_visit_method}(new_node)"
191
+ elsif children_of_type
192
+ children_of_type.map do |child_accessor, child_class|
193
+ "node.#{child_accessor}.each do |child_node|
194
+ new_child_and_node = #{child_class.visit_method}_with_modifications(child_node, new_node)
195
+ # Reassign `node` in case the child hook makes a modification
196
+ if new_child_and_node.is_a?(Array)
197
+ new_node = new_child_and_node[1]
198
+ end
199
+ end"
200
+ end.join("\n")
201
+ else
202
+ ""
203
+ end
204
+ }
205
+
206
+ if new_node.equal?(node)
207
+ [node, parent]
208
+ else
209
+ [new_node, parent]
210
+ end
211
+ end
212
+ end
213
+
214
+ def #{node_method}_with_modifications(node, parent)
215
+ new_node_and_new_parent = #{node_method}(node, parent)
216
+ apply_modifications(node, parent, new_node_and_new_parent)
217
+ end
218
+ RUBY
219
+ end
220
+
219
221
  [
220
222
  Language::Nodes::Argument,
221
223
  Language::Nodes::Directive,
@@ -256,6 +258,8 @@ module GraphQL
256
258
  make_visit_methods(ast_node_class)
257
259
  end
258
260
 
261
+ # rubocop:enable Development/NoEvalCop
262
+
259
263
  private
260
264
 
261
265
  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
 
@@ -451,17 +451,18 @@ module GraphQL
451
451
 
452
452
  # Don't do this for interfaces
453
453
  if default_resolve
454
- owner.class_eval <<-RUBY, __FILE__, __LINE__
455
- # frozen_string_literal: true
456
- def #{resolve_method_name}(**args)
457
- field_instance = self.class.get_field("#{field_definition.name}")
458
- context.schema.definition_default_resolve.call(self.class, field_instance, object, args, context)
459
- end
460
- RUBY
454
+ define_field_resolve_method(owner, resolve_method_name, field_definition.name)
461
455
  end
462
456
  end
463
457
  end
464
458
 
459
+ def define_field_resolve_method(owner, method_name, field_name)
460
+ owner.define_method(method_name) { |**args|
461
+ field_instance = self.class.get_field(field_name)
462
+ context.schema.definition_default_resolve.call(self.class, field_instance, object, args, context)
463
+ }
464
+ end
465
+
465
466
  def build_resolve_type(lookup_hash, directives, missing_type_handler)
466
467
  resolve_type_proc = nil
467
468
  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
@@ -29,7 +29,7 @@ module GraphQL
29
29
  const_set(:DefinitionMethods, defn_methods_module)
30
30
  extend(self::DefinitionMethods)
31
31
  end
32
- self::DefinitionMethods.module_eval(&block)
32
+ self::DefinitionMethods.module_exec(&block)
33
33
  end
34
34
 
35
35
  # @see {Schema::Warden} hides interfaces without visible implementations
@@ -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)
@@ -183,7 +183,7 @@ module GraphQL
183
183
 
184
184
  def inherited(subclass)
185
185
  super
186
- subclass.class_eval do
186
+ subclass.class_exec do
187
187
  @own_fields ||= nil
188
188
  @field_class ||= nil
189
189
  end
@@ -133,7 +133,7 @@ module GraphQL
133
133
 
134
134
  def inherited(subclass)
135
135
  super
136
- subclass.class_eval do
136
+ subclass.class_exec do
137
137
  @own_interface_type_memberships ||= nil
138
138
  end
139
139
  end
@@ -30,7 +30,7 @@ module GraphQL
30
30
 
31
31
  def inherited(subclass)
32
32
  super
33
- subclass.class_eval do
33
+ subclass.class_exec do
34
34
  @reauthorize_scoped_objects = nil
35
35
  end
36
36
  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.1.13"
3
+ VERSION = "2.1.15"
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.1.13
4
+ version: 2.1.15
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: 2024-07-17 00:00:00.000000000 Z
11
+ date: 2025-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: racc
@@ -614,7 +614,7 @@ metadata:
614
614
  source_code_uri: https://github.com/rmosolgo/graphql-ruby
615
615
  bug_tracker_uri: https://github.com/rmosolgo/graphql-ruby/issues
616
616
  mailing_list_uri: https://tinyletter.com/graphql-ruby
617
- post_install_message:
617
+ post_install_message:
618
618
  rdoc_options: []
619
619
  require_paths:
620
620
  - lib
@@ -629,8 +629,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
629
629
  - !ruby/object:Gem::Version
630
630
  version: '0'
631
631
  requirements: []
632
- rubygems_version: 3.5.12
633
- signing_key:
632
+ rubygems_version: 3.1.6
633
+ signing_key:
634
634
  specification_version: 4
635
635
  summary: A GraphQL language and runtime for Ruby
636
636
  test_files: []