graphql 1.13.11 → 1.13.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/argument.rb +1 -1
- data/lib/graphql/base_type.rb +1 -1
- data/lib/graphql/define/instance_definable.rb +15 -0
- data/lib/graphql/directive.rb +1 -1
- data/lib/graphql/enum_type.rb +2 -2
- data/lib/graphql/field.rb +1 -1
- data/lib/graphql/input_object_type.rb +1 -1
- data/lib/graphql/interface_type.rb +1 -1
- data/lib/graphql/object_type.rb +2 -2
- data/lib/graphql/relay/mutation.rb +1 -1
- data/lib/graphql/scalar_type.rb +1 -1
- data/lib/graphql/schema/field.rb +2 -0
- data/lib/graphql/schema.rb +2 -1
- data/lib/graphql/tracing/data_dog_tracing.rb +19 -2
- data/lib/graphql/tracing/opentelemetry_tracing.rb +101 -0
- data/lib/graphql/tracing/platform_tracing.rb +8 -4
- data/lib/graphql/tracing.rb +1 -0
- data/lib/graphql/union_type.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '032739327be4e27b1c7d2dbc3d24a5db771a713ec683238da1e9cd850993ff73'
|
4
|
+
data.tar.gz: b8c12e62126d761283086ccda4095812db080611b463bb0770603ea85c965c02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1a66366e1cceae9717bf8a4dc902cf9a670cee49e5017d45d7b9375149f579fa54f31ed0d47b73f71552c4b9c62de108f29eaa2ad59a6bc5fcf8cff7bc2bbc8
|
7
|
+
data.tar.gz: d83ce36125d77157290b60d0b66dbb01a7a3c8eac6d5f99c4c025e0e4cc511917d04c01a53357f74fd7554fcbf3ec91d5ead5b25c7a718565a6bf8b198de50fc
|
data/lib/graphql/argument.rb
CHANGED
@@ -3,7 +3,7 @@ module GraphQL
|
|
3
3
|
# @api deprecated
|
4
4
|
class Argument
|
5
5
|
include GraphQL::Define::InstanceDefinable
|
6
|
-
|
6
|
+
deprecated_accepts_definitions :name, :type, :description, :default_value, :as, :prepare, :method_access, :deprecation_reason
|
7
7
|
attr_reader :default_value
|
8
8
|
attr_accessor :description, :name, :as, :deprecation_reason
|
9
9
|
attr_accessor :ast_node
|
data/lib/graphql/base_type.rb
CHANGED
@@ -167,6 +167,21 @@ ERR
|
|
167
167
|
# Each symbol in `accepts` will be assigned with `{key}=`.
|
168
168
|
# The last entry in accepts may be a hash of name-proc pairs for custom definitions.
|
169
169
|
def accepts_definitions(*accepts)
|
170
|
+
deprecated_caller = caller(0, 1).first
|
171
|
+
if deprecated_caller.include?("lib/graphql")
|
172
|
+
deprecated_caller = caller(2, 10).find { |c| !c.include?("lib/graphql") }
|
173
|
+
end
|
174
|
+
|
175
|
+
if deprecated_caller
|
176
|
+
GraphQL::Deprecation.warn <<-ERR
|
177
|
+
#{self}.accepts_definitions will be removed in GraphQL-Ruby 2.0; use a class-based definition instead. See https://graphql-ruby.org/schema/class_based_api.html.
|
178
|
+
-> called from #{deprecated_caller}
|
179
|
+
ERR
|
180
|
+
end
|
181
|
+
deprecated_accepts_definitions(*accepts)
|
182
|
+
end
|
183
|
+
|
184
|
+
def deprecated_accepts_definitions(*accepts)
|
170
185
|
new_assignments = if accepts.last.is_a?(Hash)
|
171
186
|
accepts.pop.dup
|
172
187
|
else
|
data/lib/graphql/directive.rb
CHANGED
@@ -8,7 +8,7 @@ module GraphQL
|
|
8
8
|
#
|
9
9
|
class Directive
|
10
10
|
include GraphQL::Define::InstanceDefinable
|
11
|
-
|
11
|
+
deprecated_accepts_definitions :locations, :name, :description, :arguments, :default_directive, argument: GraphQL::Define::AssignArgument
|
12
12
|
|
13
13
|
attr_accessor :locations, :arguments, :name, :description, :arguments_class
|
14
14
|
attr_accessor :ast_node
|
data/lib/graphql/enum_type.rb
CHANGED
@@ -4,7 +4,7 @@ module GraphQL
|
|
4
4
|
class EnumType < GraphQL::BaseType
|
5
5
|
extend Define::InstanceDefinable::DeprecatedDefine
|
6
6
|
|
7
|
-
|
7
|
+
deprecated_accepts_definitions :values, value: GraphQL::Define::AssignEnumValue
|
8
8
|
ensure_defined(:values, :validate_non_null_input, :coerce_non_null_input, :coerce_result)
|
9
9
|
attr_accessor :ast_node
|
10
10
|
|
@@ -72,7 +72,7 @@ module GraphQL
|
|
72
72
|
class EnumValue
|
73
73
|
include GraphQL::Define::InstanceDefinable
|
74
74
|
ATTRIBUTES = [:name, :description, :deprecation_reason, :value]
|
75
|
-
|
75
|
+
deprecated_accepts_definitions(*ATTRIBUTES)
|
76
76
|
attr_accessor(*ATTRIBUTES)
|
77
77
|
attr_accessor :ast_node
|
78
78
|
ensure_defined(*ATTRIBUTES)
|
data/lib/graphql/field.rb
CHANGED
@@ -5,7 +5,7 @@ module GraphQL
|
|
5
5
|
# @api deprecated
|
6
6
|
class Field
|
7
7
|
include GraphQL::Define::InstanceDefinable
|
8
|
-
|
8
|
+
deprecated_accepts_definitions :name, :description, :deprecation_reason,
|
9
9
|
:resolve, :lazy_resolve,
|
10
10
|
:type, :arguments,
|
11
11
|
:property, :hash_key, :complexity,
|
@@ -4,7 +4,7 @@ module GraphQL
|
|
4
4
|
class InputObjectType < GraphQL::BaseType
|
5
5
|
extend Define::InstanceDefinable::DeprecatedDefine
|
6
6
|
|
7
|
-
|
7
|
+
deprecated_accepts_definitions(
|
8
8
|
:arguments, :mutation,
|
9
9
|
input_field: GraphQL::Define::AssignArgument,
|
10
10
|
argument: GraphQL::Define::AssignArgument
|
@@ -4,7 +4,7 @@ module GraphQL
|
|
4
4
|
class InterfaceType < GraphQL::BaseType
|
5
5
|
extend Define::InstanceDefinable::DeprecatedDefine
|
6
6
|
|
7
|
-
|
7
|
+
deprecated_accepts_definitions :fields, :orphan_types, :resolve_type, field: GraphQL::Define::AssignObjectField
|
8
8
|
|
9
9
|
attr_accessor :fields, :orphan_types, :resolve_type_proc
|
10
10
|
attr_writer :type_membership_class
|
data/lib/graphql/object_type.rb
CHANGED
@@ -4,8 +4,8 @@ module GraphQL
|
|
4
4
|
class ObjectType < GraphQL::BaseType
|
5
5
|
extend Define::InstanceDefinable::DeprecatedDefine
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
deprecated_accepts_definitions :interfaces, :fields, :mutation, :relay_node_type, field: GraphQL::Define::AssignObjectField
|
8
|
+
deprecated_accepts_definitions implements: ->(type, *interfaces, inherit: false) { type.implements(interfaces, inherit: inherit) }
|
9
9
|
|
10
10
|
attr_accessor :fields, :mutation, :relay_node_type
|
11
11
|
ensure_defined(:fields, :mutation, :interfaces, :relay_node_type)
|
data/lib/graphql/scalar_type.rb
CHANGED
@@ -4,7 +4,7 @@ module GraphQL
|
|
4
4
|
class ScalarType < GraphQL::BaseType
|
5
5
|
extend Define::InstanceDefinable::DeprecatedDefine
|
6
6
|
|
7
|
-
|
7
|
+
deprecated_accepts_definitions :coerce, :coerce_input, :coerce_result
|
8
8
|
ensure_defined :coerce_non_null_input, :coerce_result
|
9
9
|
|
10
10
|
module NoOpCoerce
|
data/lib/graphql/schema/field.rb
CHANGED
@@ -176,6 +176,8 @@ module GraphQL
|
|
176
176
|
|
177
177
|
# @return Boolean
|
178
178
|
attr_reader :relay_node_field
|
179
|
+
# @return Boolean
|
180
|
+
attr_reader :relay_nodes_field
|
179
181
|
|
180
182
|
# @return [Boolean] Should we warn if this field's name conflicts with a built-in method?
|
181
183
|
def method_conflict_warning?
|
data/lib/graphql/schema.rb
CHANGED
@@ -161,7 +161,7 @@ module GraphQL
|
|
161
161
|
include LazyHandlingMethods
|
162
162
|
extend LazyHandlingMethods
|
163
163
|
|
164
|
-
|
164
|
+
deprecated_accepts_definitions \
|
165
165
|
:query_execution_strategy, :mutation_execution_strategy, :subscription_execution_strategy,
|
166
166
|
:validate_timeout, :validate_max_errors, :max_depth, :max_complexity, :default_max_page_size,
|
167
167
|
:orphan_types, :resolve_type, :type_error, :parse_error,
|
@@ -1730,6 +1730,7 @@ module GraphQL
|
|
1730
1730
|
{
|
1731
1731
|
backtrace: ctx[:backtrace],
|
1732
1732
|
tracers: ctx[:tracers],
|
1733
|
+
dataloader: ctx[:dataloader],
|
1733
1734
|
}
|
1734
1735
|
else
|
1735
1736
|
{}
|
@@ -17,15 +17,21 @@ module GraphQL
|
|
17
17
|
def platform_trace(platform_key, key, data)
|
18
18
|
tracer.trace(platform_key, service: service_name) do |span|
|
19
19
|
span.span_type = 'custom'
|
20
|
+
if defined?(Datadog::Tracing::Metadata::Ext) # Introduced in ddtrace 1.0
|
21
|
+
span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, 'graphql')
|
22
|
+
span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, key)
|
23
|
+
end
|
20
24
|
|
21
25
|
if key == 'execute_multiplex'
|
22
26
|
operations = data[:multiplex].queries.map(&:selected_operation_name).join(', ')
|
23
|
-
|
27
|
+
|
28
|
+
resource = if operations.empty?
|
24
29
|
first_query = data[:multiplex].queries.first
|
25
30
|
fallback_transaction_name(first_query && first_query.context)
|
26
31
|
else
|
27
32
|
operations
|
28
33
|
end
|
34
|
+
span.resource = resource if resource
|
29
35
|
|
30
36
|
# For top span of query, set the analytics sample rate tag, if available.
|
31
37
|
if analytics_enabled?
|
@@ -39,6 +45,8 @@ module GraphQL
|
|
39
45
|
span.set_tag(:query_string, data[:query].query_string)
|
40
46
|
end
|
41
47
|
|
48
|
+
prepare_span(key, data, span)
|
49
|
+
|
42
50
|
yield
|
43
51
|
end
|
44
52
|
end
|
@@ -47,8 +55,17 @@ module GraphQL
|
|
47
55
|
options.fetch(:service, 'ruby-graphql')
|
48
56
|
end
|
49
57
|
|
58
|
+
# Implement this method in a subclass to apply custom tags to datadog spans
|
59
|
+
# @param key [String] The event being traced
|
60
|
+
# @param data [Hash] The runtime data for this event (@see GraphQL::Tracing for keys for each event)
|
61
|
+
# @param span [Datadog::Tracing::SpanOperation] The datadog span for this event
|
62
|
+
def prepare_span(key, data, span)
|
63
|
+
end
|
64
|
+
|
50
65
|
def tracer
|
51
|
-
|
66
|
+
default_tracer = defined?(Datadog::Tracing) ? Datadog::Tracing : Datadog.tracer
|
67
|
+
|
68
|
+
options.fetch(:tracer, default_tracer)
|
52
69
|
end
|
53
70
|
|
54
71
|
def analytics_available?
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Tracing
|
5
|
+
class OpenTelemetryTracing < PlatformTracing
|
6
|
+
self.platform_keys = {
|
7
|
+
'lex' => 'graphql.lex',
|
8
|
+
'parse' => 'graphql.parse',
|
9
|
+
'validate' => 'graphql.validate',
|
10
|
+
'analyze_query' => 'graphql.analyze_query',
|
11
|
+
'analyze_multiplex' => 'graphql.analyze_multiplex',
|
12
|
+
'execute_query' => 'graphql.execute_query',
|
13
|
+
'execute_query_lazy' => 'graphql.execute_query_lazy',
|
14
|
+
'execute_multiplex' => 'graphql.execute_multiplex'
|
15
|
+
}
|
16
|
+
|
17
|
+
def platform_trace(platform_key, key, data)
|
18
|
+
return yield if platform_key.nil?
|
19
|
+
|
20
|
+
tracer.in_span(platform_key, attributes: attributes_for(key, data)) do |span, _context|
|
21
|
+
yield.tap do |response|
|
22
|
+
errors = response[:errors]&.compact&.map { |e| e.to_h }&.to_json if key == 'validate'
|
23
|
+
unless errors.nil?
|
24
|
+
span.add_event(
|
25
|
+
'graphql.validation.error',
|
26
|
+
attributes: {
|
27
|
+
'message' => errors
|
28
|
+
}
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def platform_field_key(type, field)
|
36
|
+
"#{type.graphql_name}.#{field.graphql_name}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def platform_authorized_key(type)
|
40
|
+
"#{type.graphql_name}.authorized"
|
41
|
+
end
|
42
|
+
|
43
|
+
def platform_resolve_type_key(type)
|
44
|
+
"#{type.graphql_name}.resolve_type"
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def tracer
|
50
|
+
OpenTelemetry::Instrumentation::GraphQL::Instrumentation.instance.tracer
|
51
|
+
end
|
52
|
+
|
53
|
+
def config
|
54
|
+
OpenTelemetry::Instrumentation::GraphQL::Instrumentation.instance.config
|
55
|
+
end
|
56
|
+
|
57
|
+
def platform_key_enabled?(ctx, key)
|
58
|
+
return false unless config[key]
|
59
|
+
|
60
|
+
ns = ctx.namespace(:opentelemetry)
|
61
|
+
return true if ns.empty? # restores original behavior so that keys are returned if tracing is not set in context.
|
62
|
+
return false unless ns.key?(key) && ns[key]
|
63
|
+
|
64
|
+
return true
|
65
|
+
end
|
66
|
+
|
67
|
+
def attributes_for(key, data)
|
68
|
+
attributes = {}
|
69
|
+
case key
|
70
|
+
when 'execute_query'
|
71
|
+
attributes['selected_operation_name'] = data[:query].selected_operation_name if data[:query].selected_operation_name
|
72
|
+
attributes['selected_operation_type'] = data[:query].selected_operation.operation_type
|
73
|
+
attributes['query_string'] = data[:query].query_string
|
74
|
+
end
|
75
|
+
attributes
|
76
|
+
end
|
77
|
+
|
78
|
+
def cached_platform_key(ctx, key, trace_phase)
|
79
|
+
cache = ctx.namespace(self.class)[:platform_key_cache] ||= {}
|
80
|
+
|
81
|
+
cache.fetch(key) do
|
82
|
+
cache[key] = if trace_phase == :field
|
83
|
+
return unless platform_key_enabled?(ctx, :enable_platform_field)
|
84
|
+
|
85
|
+
yield
|
86
|
+
elsif trace_phase == :authorized
|
87
|
+
return unless platform_key_enabled?(ctx, :enable_platform_authorized)
|
88
|
+
|
89
|
+
yield
|
90
|
+
elsif trace_phase == :resolve_type
|
91
|
+
return unless platform_key_enabled?(ctx, :enable_platform_resolve_type)
|
92
|
+
|
93
|
+
yield
|
94
|
+
else
|
95
|
+
raise "Unknown trace phase"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -10,6 +10,10 @@ module GraphQL
|
|
10
10
|
class PlatformTracing
|
11
11
|
class << self
|
12
12
|
attr_accessor :platform_keys
|
13
|
+
|
14
|
+
def inherited(child_class)
|
15
|
+
child_class.platform_keys = self.platform_keys
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
def initialize(options = {})
|
@@ -41,7 +45,7 @@ module GraphQL
|
|
41
45
|
|
42
46
|
platform_key = if trace_field
|
43
47
|
context = data.fetch(:query).context
|
44
|
-
cached_platform_key(context, field) { platform_field_key(data[:owner], field) }
|
48
|
+
cached_platform_key(context, field, :field) { platform_field_key(data[:owner], field) }
|
45
49
|
else
|
46
50
|
nil
|
47
51
|
end
|
@@ -57,14 +61,14 @@ module GraphQL
|
|
57
61
|
when "authorized", "authorized_lazy"
|
58
62
|
type = data.fetch(:type)
|
59
63
|
context = data.fetch(:context)
|
60
|
-
platform_key = cached_platform_key(context, type) { platform_authorized_key(type) }
|
64
|
+
platform_key = cached_platform_key(context, type, :authorized) { platform_authorized_key(type) }
|
61
65
|
platform_trace(platform_key, key, data) do
|
62
66
|
yield
|
63
67
|
end
|
64
68
|
when "resolve_type", "resolve_type_lazy"
|
65
69
|
type = data.fetch(:type)
|
66
70
|
context = data.fetch(:context)
|
67
|
-
platform_key = cached_platform_key(context, type) { platform_resolve_type_key(type) }
|
71
|
+
platform_key = cached_platform_key(context, type, :resolve_type) { platform_resolve_type_key(type) }
|
68
72
|
platform_trace(platform_key, key, data) do
|
69
73
|
yield
|
70
74
|
end
|
@@ -135,7 +139,7 @@ module GraphQL
|
|
135
139
|
# If the key isn't present, the given block is called and the result is cached for `key`.
|
136
140
|
#
|
137
141
|
# @return [String]
|
138
|
-
def cached_platform_key(ctx, key)
|
142
|
+
def cached_platform_key(ctx, key, trace_phase)
|
139
143
|
cache = ctx.namespace(self.class)[:platform_key_cache] ||= {}
|
140
144
|
cache.fetch(key) { cache[key] = yield }
|
141
145
|
end
|
data/lib/graphql/tracing.rb
CHANGED
@@ -9,6 +9,7 @@ require "graphql/tracing/scout_tracing"
|
|
9
9
|
require "graphql/tracing/skylight_tracing"
|
10
10
|
require "graphql/tracing/statsd_tracing"
|
11
11
|
require "graphql/tracing/prometheus_tracing"
|
12
|
+
require "graphql/tracing/opentelemetry_tracing"
|
12
13
|
|
13
14
|
if defined?(PrometheusExporter::Server)
|
14
15
|
require "graphql/tracing/prometheus_tracing/graphql_collector"
|
data/lib/graphql/union_type.rb
CHANGED
@@ -11,7 +11,7 @@ module GraphQL
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
deprecated_accepts_definitions :resolve_type, :type_membership_class,
|
15
15
|
possible_types: AcceptPossibleTypesDefinition
|
16
16
|
ensure_defined :possible_types, :resolve_type, :resolve_type_proc, :type_membership_class
|
17
17
|
|
data/lib/graphql/version.rb
CHANGED
data/lib/graphql.rb
CHANGED
@@ -83,6 +83,7 @@ require "graphql/string_encoding_error"
|
|
83
83
|
require "graphql/date_encoding_error"
|
84
84
|
|
85
85
|
require "graphql/define"
|
86
|
+
require "graphql/deprecation"
|
86
87
|
require "graphql/base_type"
|
87
88
|
require "graphql/object_type"
|
88
89
|
require "graphql/enum_type"
|
@@ -119,7 +120,6 @@ require "graphql/internal_representation"
|
|
119
120
|
require "graphql/directive"
|
120
121
|
require "graphql/static_validation"
|
121
122
|
require "graphql/execution"
|
122
|
-
require "graphql/deprecation"
|
123
123
|
require "graphql/boolean_type"
|
124
124
|
require "graphql/float_type"
|
125
125
|
require "graphql/id_type"
|
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: 1.13.
|
4
|
+
version: 1.13.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -659,6 +659,7 @@ files:
|
|
659
659
|
- lib/graphql/tracing/data_dog_tracing.rb
|
660
660
|
- lib/graphql/tracing/new_relic_tracing.rb
|
661
661
|
- lib/graphql/tracing/notifications_tracing.rb
|
662
|
+
- lib/graphql/tracing/opentelemetry_tracing.rb
|
662
663
|
- lib/graphql/tracing/platform_tracing.rb
|
663
664
|
- lib/graphql/tracing/prometheus_tracing.rb
|
664
665
|
- lib/graphql/tracing/prometheus_tracing/graphql_collector.rb
|
@@ -722,7 +723,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
722
723
|
- !ruby/object:Gem::Version
|
723
724
|
version: '0'
|
724
725
|
requirements: []
|
725
|
-
rubygems_version: 3.
|
726
|
+
rubygems_version: 3.2.22
|
726
727
|
signing_key:
|
727
728
|
specification_version: 4
|
728
729
|
summary: A GraphQL language and runtime for Ruby
|