graphql 2.2.5 → 2.2.10
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 +4 -4
- data/lib/graphql/analysis/ast/field_usage.rb +32 -7
- data/lib/graphql/analysis/ast.rb +7 -1
- data/lib/graphql/coercion_error.rb +1 -9
- data/lib/graphql/dataloader/request.rb +5 -0
- data/lib/graphql/execution/interpreter/runtime.rb +9 -0
- data/lib/graphql/execution/interpreter.rb +90 -150
- data/lib/graphql/introspection/entry_points.rb +9 -3
- data/lib/graphql/introspection/schema_type.rb +3 -1
- data/lib/graphql/language/document_from_schema_definition.rb +1 -2
- data/lib/graphql/language/nodes.rb +1 -1
- data/lib/graphql/language/parser.rb +11 -1
- data/lib/graphql/language/printer.rb +4 -0
- data/lib/graphql/pagination/array_connection.rb +3 -3
- data/lib/graphql/pagination/relation_connection.rb +3 -3
- data/lib/graphql/query/validation_pipeline.rb +2 -2
- data/lib/graphql/query/variables.rb +3 -3
- data/lib/graphql/query.rb +1 -1
- data/lib/graphql/schema/base_64_encoder.rb +3 -5
- data/lib/graphql/schema/field.rb +31 -30
- data/lib/graphql/schema/interface.rb +5 -1
- data/lib/graphql/schema/resolver.rb +9 -5
- data/lib/graphql/schema/unique_within_type.rb +1 -1
- data/lib/graphql/schema.rb +49 -7
- data/lib/graphql/static_validation/literal_validator.rb +1 -2
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +1 -1
- data/lib/graphql/static_validation/validator.rb +3 -0
- data/lib/graphql/subscriptions/serialize.rb +2 -0
- data/lib/graphql/subscriptions.rb +0 -3
- data/lib/graphql/testing/helpers.rb +8 -4
- data/lib/graphql/tracing/data_dog_trace.rb +21 -34
- data/lib/graphql/tracing/data_dog_tracing.rb +7 -21
- data/lib/graphql/tracing/legacy_hooks_trace.rb +74 -0
- data/lib/graphql/tracing/platform_tracing.rb +2 -0
- data/lib/graphql/tracing/{prometheus_tracing → prometheus_trace}/graphql_collector.rb +3 -1
- data/lib/graphql/tracing/sentry_trace.rb +95 -0
- data/lib/graphql/tracing.rb +3 -1
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +3 -2
- metadata +24 -23
- data/lib/graphql/schema/base_64_bp.rb +0 -26
- data/lib/graphql/subscriptions/instrumentation.rb +0 -28
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Tracing
|
5
|
+
module SentryTrace
|
6
|
+
include PlatformTrace
|
7
|
+
|
8
|
+
{
|
9
|
+
"lex" => "graphql.lex",
|
10
|
+
"parse" => "graphql.parse",
|
11
|
+
"validate" => "graphql.validate",
|
12
|
+
"analyze_query" => "graphql.analyze",
|
13
|
+
"analyze_multiplex" => "graphql.analyze_multiplex",
|
14
|
+
"execute_multiplex" => "graphql.execute_multiplex",
|
15
|
+
"execute_query" => "graphql.execute",
|
16
|
+
"execute_query_lazy" => "graphql.execute"
|
17
|
+
}.each do |trace_method, platform_key|
|
18
|
+
module_eval <<-RUBY, __FILE__, __LINE__
|
19
|
+
def #{trace_method}(**data)
|
20
|
+
instrument_execution("#{platform_key}", "#{trace_method}", data) { super }
|
21
|
+
end
|
22
|
+
RUBY
|
23
|
+
end
|
24
|
+
|
25
|
+
def platform_execute_field(platform_key, &block)
|
26
|
+
instrument_execution(platform_key, "execute_field", &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def platform_execute_field_lazy(platform_key, &block)
|
30
|
+
instrument_execution(platform_key, "execute_field_lazy", &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
def platform_authorized(platform_key, &block)
|
34
|
+
instrument_execution(platform_key, "authorized", &block)
|
35
|
+
end
|
36
|
+
|
37
|
+
def platform_authorized_lazy(platform_key, &block)
|
38
|
+
instrument_execution(platform_key, "authorized_lazy", &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def platform_resolve_type(platform_key, &block)
|
42
|
+
instrument_execution(platform_key, "resolve_type", &block)
|
43
|
+
end
|
44
|
+
|
45
|
+
def platform_resolve_type_lazy(platform_key, &block)
|
46
|
+
instrument_execution(platform_key, "resolve_type_lazy", &block)
|
47
|
+
end
|
48
|
+
|
49
|
+
def platform_field_key(field)
|
50
|
+
"graphql.field.#{field.path}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def platform_authorized_key(type)
|
54
|
+
"graphql.authorized.#{type.graphql_name}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def platform_resolve_type_key(type)
|
58
|
+
"graphql.resolve_type.#{type.graphql_name}"
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def instrument_execution(platform_key, trace_method, data=nil, &block)
|
64
|
+
return yield unless Sentry.initialized?
|
65
|
+
|
66
|
+
Sentry.with_child_span(op: platform_key, start_timestamp: Sentry.utc_now.to_f) do |span|
|
67
|
+
result = yield
|
68
|
+
return result unless span
|
69
|
+
|
70
|
+
span.finish
|
71
|
+
if trace_method == "execute_multiplex" && data.key?(:multiplex)
|
72
|
+
operation_names = data[:multiplex].queries.map{|q| operation_name(q) }
|
73
|
+
span.set_description(operation_names.join(", "))
|
74
|
+
elsif trace_method == "execute_query" && data.key?(:query)
|
75
|
+
span.set_description(operation_name(data[:query]))
|
76
|
+
span.set_data('graphql.document', data[:query].query_string)
|
77
|
+
span.set_data('graphql.operation.name', data[:query].selected_operation_name) if data[:query].selected_operation_name
|
78
|
+
span.set_data('graphql.operation.type', data[:query].selected_operation.operation_type)
|
79
|
+
end
|
80
|
+
|
81
|
+
result
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def operation_name(query)
|
86
|
+
selected_op = query.selected_operation
|
87
|
+
if selected_op
|
88
|
+
[selected_op.operation_type, selected_op.name].compact.join(' ')
|
89
|
+
else
|
90
|
+
'GraphQL Operation'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
data/lib/graphql/tracing.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "graphql/tracing/trace"
|
3
3
|
require "graphql/tracing/legacy_trace"
|
4
|
+
require "graphql/tracing/legacy_hooks_trace"
|
4
5
|
|
5
6
|
# Legacy tracing:
|
6
7
|
require "graphql/tracing/active_support_notifications_tracing"
|
@@ -21,11 +22,12 @@ require "graphql/tracing/appsignal_trace"
|
|
21
22
|
require "graphql/tracing/data_dog_trace"
|
22
23
|
require "graphql/tracing/new_relic_trace"
|
23
24
|
require "graphql/tracing/notifications_trace"
|
25
|
+
require "graphql/tracing/sentry_trace"
|
24
26
|
require "graphql/tracing/scout_trace"
|
25
27
|
require "graphql/tracing/statsd_trace"
|
26
28
|
require "graphql/tracing/prometheus_trace"
|
27
29
|
if defined?(PrometheusExporter::Server)
|
28
|
-
require "graphql/tracing/
|
30
|
+
require "graphql/tracing/prometheus_trace/graphql_collector"
|
29
31
|
end
|
30
32
|
|
31
33
|
module GraphQL
|
data/lib/graphql/version.rb
CHANGED
data/lib/graphql.rb
CHANGED
@@ -42,8 +42,8 @@ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: http
|
|
42
42
|
# Turn a query string or schema definition into an AST
|
43
43
|
# @param graphql_string [String] a GraphQL query string or schema definition
|
44
44
|
# @return [GraphQL::Language::Nodes::Document]
|
45
|
-
def self.parse(graphql_string, trace: GraphQL::Tracing::NullTrace)
|
46
|
-
default_parser.parse(graphql_string, trace: trace)
|
45
|
+
def self.parse(graphql_string, trace: GraphQL::Tracing::NullTrace, filename: nil)
|
46
|
+
default_parser.parse(graphql_string, trace: trace, filename: filename)
|
47
47
|
end
|
48
48
|
|
49
49
|
# Read the contents of `filename` and parse them as GraphQL
|
@@ -60,6 +60,7 @@ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: http
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def self.parse_with_racc(string, filename: nil, trace: GraphQL::Tracing::NullTrace)
|
63
|
+
warn "`GraphQL.parse_with_racc` is deprecated; GraphQL-Ruby no longer uses racc for parsing. Call `GraphQL.parse` or `GraphQL::Language::Parser.parse` instead."
|
63
64
|
GraphQL::Language::Parser.parse(string, filename: filename, trace: trace)
|
64
65
|
end
|
65
66
|
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.10
|
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-
|
11
|
+
date: 2024-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: base64
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: benchmark-ips
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,44 +70,44 @@ dependencies:
|
|
70
70
|
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: minitest-focus
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: minitest-reporters
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -400,7 +400,6 @@ files:
|
|
400
400
|
- lib/graphql/schema/addition.rb
|
401
401
|
- lib/graphql/schema/always_visible.rb
|
402
402
|
- lib/graphql/schema/argument.rb
|
403
|
-
- lib/graphql/schema/base_64_bp.rb
|
404
403
|
- lib/graphql/schema/base_64_encoder.rb
|
405
404
|
- lib/graphql/schema/build_from_definition.rb
|
406
405
|
- lib/graphql/schema/build_from_definition/resolve_map.rb
|
@@ -550,7 +549,6 @@ files:
|
|
550
549
|
- lib/graphql/subscriptions/broadcast_analyzer.rb
|
551
550
|
- lib/graphql/subscriptions/default_subscription_resolve_extension.rb
|
552
551
|
- lib/graphql/subscriptions/event.rb
|
553
|
-
- lib/graphql/subscriptions/instrumentation.rb
|
554
552
|
- lib/graphql/subscriptions/serialize.rb
|
555
553
|
- lib/graphql/testing.rb
|
556
554
|
- lib/graphql/testing/helpers.rb
|
@@ -563,6 +561,7 @@ files:
|
|
563
561
|
- lib/graphql/tracing/appsignal_tracing.rb
|
564
562
|
- lib/graphql/tracing/data_dog_trace.rb
|
565
563
|
- lib/graphql/tracing/data_dog_tracing.rb
|
564
|
+
- lib/graphql/tracing/legacy_hooks_trace.rb
|
566
565
|
- lib/graphql/tracing/legacy_trace.rb
|
567
566
|
- lib/graphql/tracing/new_relic_trace.rb
|
568
567
|
- lib/graphql/tracing/new_relic_tracing.rb
|
@@ -571,10 +570,11 @@ files:
|
|
571
570
|
- lib/graphql/tracing/platform_trace.rb
|
572
571
|
- lib/graphql/tracing/platform_tracing.rb
|
573
572
|
- lib/graphql/tracing/prometheus_trace.rb
|
573
|
+
- lib/graphql/tracing/prometheus_trace/graphql_collector.rb
|
574
574
|
- lib/graphql/tracing/prometheus_tracing.rb
|
575
|
-
- lib/graphql/tracing/prometheus_tracing/graphql_collector.rb
|
576
575
|
- lib/graphql/tracing/scout_trace.rb
|
577
576
|
- lib/graphql/tracing/scout_tracing.rb
|
577
|
+
- lib/graphql/tracing/sentry_trace.rb
|
578
578
|
- lib/graphql/tracing/statsd_trace.rb
|
579
579
|
- lib/graphql/tracing/statsd_tracing.rb
|
580
580
|
- lib/graphql/tracing/trace.rb
|
@@ -615,6 +615,7 @@ metadata:
|
|
615
615
|
source_code_uri: https://github.com/rmosolgo/graphql-ruby
|
616
616
|
bug_tracker_uri: https://github.com/rmosolgo/graphql-ruby/issues
|
617
617
|
mailing_list_uri: https://buttondown.email/graphql-ruby
|
618
|
+
rubygems_mfa_required: 'true'
|
618
619
|
post_install_message:
|
619
620
|
rdoc_options: []
|
620
621
|
require_paths:
|
@@ -630,7 +631,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
630
631
|
- !ruby/object:Gem::Version
|
631
632
|
version: '0'
|
632
633
|
requirements: []
|
633
|
-
rubygems_version: 3.
|
634
|
+
rubygems_version: 3.5.5
|
634
635
|
signing_key:
|
635
636
|
specification_version: 4
|
636
637
|
summary: A GraphQL language and runtime for Ruby
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'base64'
|
4
|
-
|
5
|
-
# backport from ruby v2.5 to v2.2 that has no `padding` things
|
6
|
-
# @api private
|
7
|
-
module Base64Bp
|
8
|
-
extend Base64
|
9
|
-
|
10
|
-
module_function
|
11
|
-
|
12
|
-
def urlsafe_encode64(bin, padding:)
|
13
|
-
str = strict_encode64(bin)
|
14
|
-
str.tr!("+/", "-_")
|
15
|
-
str.delete!("=") unless padding
|
16
|
-
str
|
17
|
-
end
|
18
|
-
|
19
|
-
def urlsafe_decode64(str)
|
20
|
-
str = str.tr("-_", "+/")
|
21
|
-
if !str.end_with?("=") && str.length % 4 != 0
|
22
|
-
str = str.ljust((str.length + 3) & ~3, "=")
|
23
|
-
end
|
24
|
-
strict_decode64(str)
|
25
|
-
end
|
26
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
class Subscriptions
|
4
|
-
# Wrap the root fields of the subscription type with special logic for:
|
5
|
-
# - Registering the subscription during the first execution
|
6
|
-
# - Evaluating the triggered portion(s) of the subscription during later execution
|
7
|
-
class Instrumentation
|
8
|
-
def initialize(schema:)
|
9
|
-
@schema = schema
|
10
|
-
end
|
11
|
-
|
12
|
-
# If needed, prepare to gather events which this query subscribes to
|
13
|
-
def before_query(query)
|
14
|
-
if query.subscription? && !query.subscription_update?
|
15
|
-
query.context.namespace(:subscriptions)[:events] = []
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# After checking the root fields, pass the gathered events to the store
|
20
|
-
def after_query(query)
|
21
|
-
events = query.context.namespace(:subscriptions)[:events]
|
22
|
-
if events && events.any?
|
23
|
-
@schema.subscriptions.write_subscription(query, events)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|