graphql 2.3.3 → 2.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/dataloader/async_dataloader.rb +1 -0
- data/lib/graphql/dataloader.rb +6 -3
- data/lib/graphql/execution/interpreter/runtime.rb +12 -4
- data/lib/graphql/language/nodes.rb +44 -5
- data/lib/graphql/language/parser.rb +2 -2
- data/lib/graphql/query.rb +1 -1
- data/lib/graphql/tracing/prometheus_trace.rb +8 -8
- data/lib/graphql/tracing/sentry_trace.rb +10 -10
- data/lib/graphql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8f2d38dd0c349521f7f22050bb70cee1f06a7832de74d5afe523a35310ed318
|
4
|
+
data.tar.gz: da047a5e11a1441060411c47468daad16300db1dc7064ab1b1a76d2e519e76fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73bd380530a4183241587083beb2ef6c96709657fb18e702a294a37c22f26e2141b2111b96c79570b9588d330e9c8d851fd532cdaf6d6fbd55f9dd5b30c6fe4e
|
7
|
+
data.tar.gz: 917e88d0cec3cbc760ec89714cf31325088f94f0a93094b3fcbf1cc3c07f52a99e30f0e418e561518c0a7deef0358dfa0ae457b8bad88fb50883aacb9d7dae7f
|
data/lib/graphql/dataloader.rb
CHANGED
@@ -88,6 +88,11 @@ module GraphQL
|
|
88
88
|
nil
|
89
89
|
end
|
90
90
|
|
91
|
+
# This method is called when Dataloader is finished using a fiber.
|
92
|
+
# Use it to perform any cleanup, such as releasing database connections (if required manually)
|
93
|
+
def cleanup_fiber
|
94
|
+
end
|
95
|
+
|
91
96
|
# Get a Source instance from this dataloader, for calling `.load(...)` or `.request(...)` on.
|
92
97
|
#
|
93
98
|
# @param source_class [Class<GraphQL::Dataloader::Source]
|
@@ -231,9 +236,7 @@ module GraphQL
|
|
231
236
|
Fiber.new(blocking: !@nonblocking) {
|
232
237
|
set_fiber_variables(fiber_vars)
|
233
238
|
yield
|
234
|
-
|
235
|
-
# if the fiber is allowed to terminate normally, control is passed to the main fiber instead.
|
236
|
-
true
|
239
|
+
cleanup_fiber
|
237
240
|
}
|
238
241
|
end
|
239
242
|
|
@@ -127,7 +127,6 @@ module GraphQL
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def gather_selections(owner_object, owner_type, selections, selections_to_run = nil, selections_by_name = {})
|
130
|
-
|
131
130
|
selections.each do |node|
|
132
131
|
# Skip gathering this if the directive says so
|
133
132
|
if !directives_include?(node, owner_object, owner_type)
|
@@ -172,17 +171,26 @@ module GraphQL
|
|
172
171
|
type_defn = schema.get_type(node.type.name, context)
|
173
172
|
|
174
173
|
if query.warden.possible_types(type_defn).include?(owner_type)
|
175
|
-
gather_selections(owner_object, owner_type, node.selections, selections_to_run, next_selections)
|
174
|
+
result = gather_selections(owner_object, owner_type, node.selections, selections_to_run, next_selections)
|
175
|
+
if !result.equal?(next_selections)
|
176
|
+
selections_to_run = result
|
177
|
+
end
|
176
178
|
end
|
177
179
|
else
|
178
180
|
# it's an untyped fragment, definitely continue
|
179
|
-
gather_selections(owner_object, owner_type, node.selections, selections_to_run, next_selections)
|
181
|
+
result = gather_selections(owner_object, owner_type, node.selections, selections_to_run, next_selections)
|
182
|
+
if !result.equal?(next_selections)
|
183
|
+
selections_to_run = result
|
184
|
+
end
|
180
185
|
end
|
181
186
|
when GraphQL::Language::Nodes::FragmentSpread
|
182
187
|
fragment_def = query.fragments[node.name]
|
183
188
|
type_defn = query.get_type(fragment_def.type.name)
|
184
189
|
if query.warden.possible_types(type_defn).include?(owner_type)
|
185
|
-
gather_selections(owner_object, owner_type, fragment_def.selections, selections_to_run, next_selections)
|
190
|
+
result = gather_selections(owner_object, owner_type, fragment_def.selections, selections_to_run, next_selections)
|
191
|
+
if !result.equal?(next_selections)
|
192
|
+
selections_to_run = result
|
193
|
+
end
|
186
194
|
end
|
187
195
|
else
|
188
196
|
raise "Invariant: unexpected selection class: #{node.class}"
|
@@ -20,6 +20,15 @@ module GraphQL
|
|
20
20
|
@definition_line = definition_line
|
21
21
|
super(**_rest)
|
22
22
|
end
|
23
|
+
|
24
|
+
def marshal_dump
|
25
|
+
super << @definition_line
|
26
|
+
end
|
27
|
+
|
28
|
+
def marshal_load(values)
|
29
|
+
@definition_line = values.pop
|
30
|
+
super
|
31
|
+
end
|
23
32
|
end
|
24
33
|
|
25
34
|
attr_reader :filename
|
@@ -273,18 +282,20 @@ module GraphQL
|
|
273
282
|
end
|
274
283
|
end
|
275
284
|
|
276
|
-
|
285
|
+
children_method_names = @children_methods.keys
|
286
|
+
|
287
|
+
all_method_names = scalar_method_names + children_method_names
|
277
288
|
if all_method_names.include?(:alias)
|
278
289
|
# Rather than complicating this special case,
|
279
290
|
# let it be overridden (in field)
|
280
291
|
return
|
281
292
|
else
|
282
293
|
arguments = scalar_method_names.map { |m| "#{m}: nil"} +
|
283
|
-
|
294
|
+
children_method_names.map { |m| "#{m}: NO_CHILDREN" } +
|
284
295
|
DEFAULT_INITIALIZE_OPTIONS
|
285
296
|
|
286
297
|
assignments = scalar_method_names.map { |m| "@#{m} = #{m}"} +
|
287
|
-
|
298
|
+
children_method_names.map { |m| "@#{m} = #{m}.freeze" }
|
288
299
|
|
289
300
|
if name.end_with?("Definition") && name != "FragmentDefinition"
|
290
301
|
arguments << "definition_pos: nil"
|
@@ -292,7 +303,7 @@ module GraphQL
|
|
292
303
|
end
|
293
304
|
|
294
305
|
keywords = scalar_method_names.map { |m| "#{m}: #{m}"} +
|
295
|
-
|
306
|
+
children_method_names.map { |m| "#{m}: #{m}" }
|
296
307
|
|
297
308
|
module_eval <<-RUBY, __FILE__, __LINE__
|
298
309
|
def initialize(#{arguments.join(", ")})
|
@@ -304,9 +315,21 @@ module GraphQL
|
|
304
315
|
#{assignments.join("\n")}
|
305
316
|
end
|
306
317
|
|
307
|
-
def self.from_a(filename, line, col, #{
|
318
|
+
def self.from_a(filename, line, col, #{all_method_names.join(", ")})
|
308
319
|
self.new(filename: filename, line: line, col: col, #{keywords.join(", ")})
|
309
320
|
end
|
321
|
+
|
322
|
+
def marshal_dump
|
323
|
+
[
|
324
|
+
line, col, # use methods here to force them to be calculated
|
325
|
+
@filename,
|
326
|
+
#{all_method_names.map { |n| "@#{n}," }.join}
|
327
|
+
]
|
328
|
+
end
|
329
|
+
|
330
|
+
def marshal_load(values)
|
331
|
+
@line, @col, @filename #{all_method_names.map { |n| ", @#{n}"}.join} = values
|
332
|
+
end
|
310
333
|
RUBY
|
311
334
|
end
|
312
335
|
end
|
@@ -397,6 +420,14 @@ module GraphQL
|
|
397
420
|
self.new(filename: filename, line: line, col: col, field_alias: field_alias, name: name, arguments: arguments, directives: directives, selections: selections)
|
398
421
|
end
|
399
422
|
|
423
|
+
def marshal_dump
|
424
|
+
[line, col, @filename, @name, @arguments, @directives, @selections, @alias]
|
425
|
+
end
|
426
|
+
|
427
|
+
def marshal_load(values)
|
428
|
+
@line, @col, @filename, @name, @arguments, @directives, @selections, @alias = values
|
429
|
+
end
|
430
|
+
|
400
431
|
# Override this because default is `:fields`
|
401
432
|
self.children_method_name = :selections
|
402
433
|
end
|
@@ -430,6 +461,14 @@ module GraphQL
|
|
430
461
|
def self.from_a(filename, line, col, name, type, directives, selections)
|
431
462
|
self.new(filename: filename, line: line, col: col, name: name, type: type, directives: directives, selections: selections)
|
432
463
|
end
|
464
|
+
|
465
|
+
def marshal_dump
|
466
|
+
[line, col, @filename, @name, @type, @directives, @selections]
|
467
|
+
end
|
468
|
+
|
469
|
+
def marshal_load(values)
|
470
|
+
@line, @col, @filename, @name, @type, @directives, @selections = values
|
471
|
+
end
|
433
472
|
end
|
434
473
|
|
435
474
|
# Application of a named fragment in a selection
|
@@ -478,7 +478,7 @@ module GraphQL
|
|
478
478
|
end
|
479
479
|
|
480
480
|
if at?(:BANG)
|
481
|
-
type = Nodes::NonNullType.new(pos: pos, of_type: type)
|
481
|
+
type = Nodes::NonNullType.new(pos: pos, of_type: type, source: self)
|
482
482
|
expect_token(:BANG)
|
483
483
|
end
|
484
484
|
type
|
@@ -487,7 +487,7 @@ module GraphQL
|
|
487
487
|
def list_type
|
488
488
|
loc = pos
|
489
489
|
expect_token(:LBRACKET)
|
490
|
-
type = Nodes::ListType.new(pos: loc, of_type: self.type)
|
490
|
+
type = Nodes::ListType.new(pos: loc, of_type: self.type, source: self)
|
491
491
|
expect_token(:RBRACKET)
|
492
492
|
type
|
493
493
|
end
|
data/lib/graphql/query.rb
CHANGED
@@ -304,7 +304,7 @@ module GraphQL
|
|
304
304
|
|
305
305
|
# @return [String] An opaque hash for identifying this query's given query string and selected operation
|
306
306
|
def operation_fingerprint
|
307
|
-
@operation_fingerprint ||= "#{selected_operation_name || "anonymous"}/#{Fingerprint.generate(query_string)}"
|
307
|
+
@operation_fingerprint ||= "#{selected_operation_name || "anonymous"}/#{Fingerprint.generate(query_string || "")}"
|
308
308
|
end
|
309
309
|
|
310
310
|
# @return [String] An opaque hash for identifying this query's given a variable values (not including defaults)
|
@@ -25,33 +25,33 @@ module GraphQL
|
|
25
25
|
}.each do |trace_method, platform_key|
|
26
26
|
module_eval <<-RUBY, __FILE__, __LINE__
|
27
27
|
def #{trace_method}(**data)
|
28
|
-
|
28
|
+
instrument_prometheus_execution("#{platform_key}", "#{trace_method}") { super }
|
29
29
|
end
|
30
30
|
RUBY
|
31
31
|
end
|
32
32
|
|
33
33
|
def platform_execute_field(platform_key, &block)
|
34
|
-
|
34
|
+
instrument_prometheus_execution(platform_key, "execute_field", &block)
|
35
35
|
end
|
36
36
|
|
37
37
|
def platform_execute_field_lazy(platform_key, &block)
|
38
|
-
|
38
|
+
instrument_prometheus_execution(platform_key, "execute_field_lazy", &block)
|
39
39
|
end
|
40
40
|
|
41
41
|
def platform_authorized(platform_key, &block)
|
42
|
-
|
42
|
+
instrument_prometheus_execution(platform_key, "authorized", &block)
|
43
43
|
end
|
44
44
|
|
45
45
|
def platform_authorized_lazy(platform_key, &block)
|
46
|
-
|
46
|
+
instrument_prometheus_execution(platform_key, "authorized_lazy", &block)
|
47
47
|
end
|
48
48
|
|
49
49
|
def platform_resolve_type(platform_key, &block)
|
50
|
-
|
50
|
+
instrument_prometheus_execution(platform_key, "resolve_type", &block)
|
51
51
|
end
|
52
52
|
|
53
53
|
def platform_resolve_type_lazy(platform_key, &block)
|
54
|
-
|
54
|
+
instrument_prometheus_execution(platform_key, "resolve_type_lazy", &block)
|
55
55
|
end
|
56
56
|
|
57
57
|
def platform_field_key(field)
|
@@ -68,7 +68,7 @@ module GraphQL
|
|
68
68
|
|
69
69
|
private
|
70
70
|
|
71
|
-
def
|
71
|
+
def instrument_prometheus_execution(platform_key, key, &block)
|
72
72
|
if @keys_whitelist.include?(key)
|
73
73
|
start = ::Process.clock_gettime ::Process::CLOCK_MONOTONIC
|
74
74
|
result = block.call
|
@@ -12,7 +12,7 @@ module GraphQL
|
|
12
12
|
@set_transaction_name = set_transaction_name
|
13
13
|
super
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def execute_query(**data)
|
17
17
|
set_this_txn_name = data[:query].context[:set_sentry_transaction_name]
|
18
18
|
if set_this_txn_name == true || (set_this_txn_name.nil? && @set_transaction_name)
|
@@ -20,7 +20,7 @@ module GraphQL
|
|
20
20
|
scope.set_transaction_name(transaction_name(data[:query]))
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
instrument_sentry_execution("graphql.execute", "execute_query", data) { super }
|
24
24
|
end
|
25
25
|
|
26
26
|
{
|
@@ -34,33 +34,33 @@ module GraphQL
|
|
34
34
|
}.each do |trace_method, platform_key|
|
35
35
|
module_eval <<-RUBY, __FILE__, __LINE__
|
36
36
|
def #{trace_method}(**data)
|
37
|
-
|
37
|
+
instrument_sentry_execution("#{platform_key}", "#{trace_method}", data) { super }
|
38
38
|
end
|
39
39
|
RUBY
|
40
40
|
end
|
41
41
|
|
42
42
|
def platform_execute_field(platform_key, &block)
|
43
|
-
|
43
|
+
instrument_sentry_execution(platform_key, "execute_field", &block)
|
44
44
|
end
|
45
45
|
|
46
46
|
def platform_execute_field_lazy(platform_key, &block)
|
47
|
-
|
47
|
+
instrument_sentry_execution(platform_key, "execute_field_lazy", &block)
|
48
48
|
end
|
49
49
|
|
50
50
|
def platform_authorized(platform_key, &block)
|
51
|
-
|
51
|
+
instrument_sentry_execution(platform_key, "authorized", &block)
|
52
52
|
end
|
53
53
|
|
54
54
|
def platform_authorized_lazy(platform_key, &block)
|
55
|
-
|
55
|
+
instrument_sentry_execution(platform_key, "authorized_lazy", &block)
|
56
56
|
end
|
57
57
|
|
58
58
|
def platform_resolve_type(platform_key, &block)
|
59
|
-
|
59
|
+
instrument_sentry_execution(platform_key, "resolve_type", &block)
|
60
60
|
end
|
61
61
|
|
62
62
|
def platform_resolve_type_lazy(platform_key, &block)
|
63
|
-
|
63
|
+
instrument_sentry_execution(platform_key, "resolve_type_lazy", &block)
|
64
64
|
end
|
65
65
|
|
66
66
|
def platform_field_key(field)
|
@@ -77,7 +77,7 @@ module GraphQL
|
|
77
77
|
|
78
78
|
private
|
79
79
|
|
80
|
-
def
|
80
|
+
def instrument_sentry_execution(platform_key, trace_method, data=nil, &block)
|
81
81
|
return yield unless Sentry.initialized?
|
82
82
|
|
83
83
|
Sentry.with_child_span(op: platform_key, start_timestamp: Sentry.utc_now.to_f) do |span|
|
data/lib/graphql/version.rb
CHANGED
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.
|
4
|
+
version: 2.3.4
|
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-05-
|
11
|
+
date: 2024-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|