graphql 2.0.17 → 2.0.18
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.rb +2 -2
- data/lib/graphql/backtrace/tracer.rb +1 -1
- data/lib/graphql/execution/interpreter/resolve.rb +19 -0
- data/lib/graphql/execution/interpreter/runtime.rb +96 -88
- data/lib/graphql/execution/interpreter.rb +8 -13
- data/lib/graphql/execution/lazy.rb +2 -4
- data/lib/graphql/execution/multiplex.rb +2 -1
- data/lib/graphql/graphql_ext.bundle +0 -0
- data/lib/graphql/language/lexer.rb +216 -1505
- data/lib/graphql/language/lexer.ri +744 -0
- data/lib/graphql/language/parser.rb +9 -9
- data/lib/graphql/language/parser.y +9 -9
- data/lib/graphql/pagination/active_record_relation_connection.rb +0 -8
- data/lib/graphql/query/context.rb +45 -11
- data/lib/graphql/query.rb +15 -2
- data/lib/graphql/schema/field.rb +31 -19
- data/lib/graphql/schema/member/has_deprecation_reason.rb +3 -4
- data/lib/graphql/schema/member/has_fields.rb +6 -1
- data/lib/graphql/schema/object.rb +2 -4
- data/lib/graphql/schema/resolver/has_payload_type.rb +9 -9
- data/lib/graphql/schema/timeout.rb +23 -27
- data/lib/graphql/schema/warden.rb +8 -1
- data/lib/graphql/schema.rb +34 -0
- data/lib/graphql/static_validation/validator.rb +1 -1
- data/lib/graphql/tracing/active_support_notifications_trace.rb +16 -0
- data/lib/graphql/tracing/appoptics_trace.rb +231 -0
- data/lib/graphql/tracing/appsignal_trace.rb +66 -0
- data/lib/graphql/tracing/data_dog_trace.rb +148 -0
- data/lib/graphql/tracing/new_relic_trace.rb +75 -0
- data/lib/graphql/tracing/notifications_trace.rb +41 -0
- data/lib/graphql/tracing/platform_trace.rb +107 -0
- data/lib/graphql/tracing/platform_tracing.rb +15 -3
- data/lib/graphql/tracing/prometheus_trace.rb +89 -0
- data/lib/graphql/tracing/prometheus_tracing.rb +3 -3
- data/lib/graphql/tracing/scout_trace.rb +72 -0
- data/lib/graphql/tracing/statsd_trace.rb +56 -0
- data/lib/graphql/tracing.rb +136 -39
- data/lib/graphql/type_kinds.rb +6 -3
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +7 -8
- metadata +14 -3
- data/lib/graphql/language/lexer.rl +0 -280
@@ -40,7 +40,7 @@ module GraphQL
|
|
40
40
|
|
41
41
|
platform_key = if trace_field
|
42
42
|
context = data.fetch(:query).context
|
43
|
-
cached_platform_key(context, field, :field) { platform_field_key(
|
43
|
+
cached_platform_key(context, field, :field) { platform_field_key(field.owner, field) }
|
44
44
|
else
|
45
45
|
nil
|
46
46
|
end
|
@@ -73,8 +73,20 @@ module GraphQL
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def self.use(schema_defn, options = {})
|
76
|
-
|
77
|
-
|
76
|
+
if options[:legacy_tracing]
|
77
|
+
tracer = self.new(**options)
|
78
|
+
schema_defn.tracer(tracer)
|
79
|
+
else
|
80
|
+
tracing_name = self.name.split("::").last
|
81
|
+
trace_name = tracing_name.sub("Tracing", "Trace")
|
82
|
+
if GraphQL::Tracing.const_defined?(trace_name, false)
|
83
|
+
trace_module = GraphQL::Tracing.const_get(trace_name)
|
84
|
+
schema_defn.trace_with(trace_module, **options)
|
85
|
+
else
|
86
|
+
tracer = self.new(**options)
|
87
|
+
schema_defn.tracer(tracer)
|
88
|
+
end
|
89
|
+
end
|
78
90
|
end
|
79
91
|
|
80
92
|
private
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Tracing
|
5
|
+
module PrometheusTrace
|
6
|
+
include PlatformTrace
|
7
|
+
|
8
|
+
def initialize(client: PrometheusExporter::Client.default, keys_whitelist: ["execute_field", "execute_field_lazy"], collector_type: "graphql", **rest)
|
9
|
+
@client = client
|
10
|
+
@keys_whitelist = keys_whitelist
|
11
|
+
@collector_type = collector_type
|
12
|
+
|
13
|
+
super(**rest)
|
14
|
+
end
|
15
|
+
|
16
|
+
{
|
17
|
+
'lex' => "graphql.lex",
|
18
|
+
'parse' => "graphql.parse",
|
19
|
+
'validate' => "graphql.validate",
|
20
|
+
'analyze_query' => "graphql.analyze",
|
21
|
+
'analyze_multiplex' => "graphql.analyze",
|
22
|
+
'execute_multiplex' => "graphql.execute",
|
23
|
+
'execute_query' => "graphql.execute",
|
24
|
+
'execute_query_lazy' => "graphql.execute",
|
25
|
+
}.each do |trace_method, platform_key|
|
26
|
+
module_eval <<-RUBY, __FILE__, __LINE__
|
27
|
+
def #{trace_method}(**data, &block)
|
28
|
+
instrument_execution("#{platform_key}", "#{trace_method}", &block)
|
29
|
+
end
|
30
|
+
RUBY
|
31
|
+
end
|
32
|
+
|
33
|
+
def platform_execute_field(platform_key, &block)
|
34
|
+
instrument_execution(platform_key, "execute_field", &block)
|
35
|
+
end
|
36
|
+
|
37
|
+
def platform_execute_field_lazy(platform_key, &block)
|
38
|
+
instrument_execution(platform_key, "execute_field_lazy", &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def platform_authorized(platform_key, &block)
|
42
|
+
instrument_execution(platform_key, "authorized", &block)
|
43
|
+
end
|
44
|
+
|
45
|
+
def platform_authorized_lazy(platform_key, &block)
|
46
|
+
instrument_execution(platform_key, "authorized_lazy", &block)
|
47
|
+
end
|
48
|
+
|
49
|
+
def platform_resolve_type(platform_key, &block)
|
50
|
+
instrument_execution(platform_key, "resolve_type", &block)
|
51
|
+
end
|
52
|
+
|
53
|
+
def platform_resolve_type_lazy(platform_key, &block)
|
54
|
+
instrument_execution(platform_key, "resolve_type_lazy", &block)
|
55
|
+
end
|
56
|
+
|
57
|
+
def platform_field_key(field)
|
58
|
+
field.path
|
59
|
+
end
|
60
|
+
|
61
|
+
def platform_authorized_key(type)
|
62
|
+
"#{type.graphql_name}.authorized"
|
63
|
+
end
|
64
|
+
|
65
|
+
def platform_resolve_type_key(type)
|
66
|
+
"#{type.graphql_name}.resolve_type"
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def instrument_execution(platform_key, key, &block)
|
72
|
+
if @keys_whitelist.include?(key)
|
73
|
+
start = ::Process.clock_gettime ::Process::CLOCK_MONOTONIC
|
74
|
+
result = block.call
|
75
|
+
duration = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start
|
76
|
+
@client.send_json(
|
77
|
+
type: @collector_type,
|
78
|
+
duration: duration,
|
79
|
+
platform_key: platform_key,
|
80
|
+
key: key
|
81
|
+
)
|
82
|
+
result
|
83
|
+
else
|
84
|
+
yield
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -27,9 +27,9 @@ module GraphQL
|
|
27
27
|
super opts
|
28
28
|
end
|
29
29
|
|
30
|
-
def platform_trace(platform_key, key,
|
30
|
+
def platform_trace(platform_key, key, _data, &block)
|
31
31
|
return yield unless @keys_whitelist.include?(key)
|
32
|
-
instrument_execution(platform_key, key,
|
32
|
+
instrument_execution(platform_key, key, &block)
|
33
33
|
end
|
34
34
|
|
35
35
|
def platform_field_key(type, field)
|
@@ -46,7 +46,7 @@ module GraphQL
|
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
-
def instrument_execution(platform_key, key,
|
49
|
+
def instrument_execution(platform_key, key, &block)
|
50
50
|
start = ::Process.clock_gettime ::Process::CLOCK_MONOTONIC
|
51
51
|
result = block.call
|
52
52
|
duration = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Tracing
|
5
|
+
module ScoutTrace
|
6
|
+
include PlatformTrace
|
7
|
+
|
8
|
+
INSTRUMENT_OPTS = { scope: true }
|
9
|
+
|
10
|
+
# @param set_transaction_name [Boolean] If true, the GraphQL operation name will be used as the transaction name.
|
11
|
+
# This is not advised if you run more than one query per HTTP request, for example, with `graphql-client` or multiplexing.
|
12
|
+
# It can also be specified per-query with `context[:set_scout_transaction_name]`.
|
13
|
+
def initialize(set_transaction_name: false, **_rest)
|
14
|
+
self.class.include(ScoutApm::Tracer)
|
15
|
+
@set_transaction_name = set_transaction_name
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
{
|
20
|
+
"lex" => "lex.graphql",
|
21
|
+
"parse" => "parse.graphql",
|
22
|
+
"validate" => "validate.graphql",
|
23
|
+
"analyze_query" => "analyze.graphql",
|
24
|
+
"analyze_multiplex" => "analyze.graphql",
|
25
|
+
"execute_multiplex" => "execute.graphql",
|
26
|
+
"execute_query" => "execute.graphql",
|
27
|
+
"execute_query_lazy" => "execute.graphql",
|
28
|
+
}.each do |trace_method, platform_key|
|
29
|
+
module_eval <<-RUBY, __FILE__, __LINE__
|
30
|
+
def #{trace_method}(**data)
|
31
|
+
#{
|
32
|
+
if trace_method == "execute_query"
|
33
|
+
<<-RUBY
|
34
|
+
set_this_txn_name = data[:query].context[:set_scout_transaction_name]
|
35
|
+
if set_this_txn_name == true || (set_this_txn_name.nil? && @set_transaction_name)
|
36
|
+
ScoutApm::Transaction.rename(transaction_name(data[:query]))
|
37
|
+
end
|
38
|
+
RUBY
|
39
|
+
end
|
40
|
+
}
|
41
|
+
|
42
|
+
self.class.instrument("GraphQL", "#{platform_key}", INSTRUMENT_OPTS) do
|
43
|
+
super
|
44
|
+
end
|
45
|
+
end
|
46
|
+
RUBY
|
47
|
+
end
|
48
|
+
|
49
|
+
def platform_execute_field(platform_key, &block)
|
50
|
+
self.class.instrument("GraphQL", platform_key, INSTRUMENT_OPTS, &block)
|
51
|
+
end
|
52
|
+
|
53
|
+
def platform_authorized(platform_key, &block)
|
54
|
+
self.class.instrument("GraphQL", platform_key, INSTRUMENT_OPTS, &block)
|
55
|
+
end
|
56
|
+
|
57
|
+
alias :platform_resolve_type :platform_authorized
|
58
|
+
|
59
|
+
def platform_field_key(field)
|
60
|
+
field.path
|
61
|
+
end
|
62
|
+
|
63
|
+
def platform_authorized_key(type)
|
64
|
+
"#{type.graphql_name}.authorized"
|
65
|
+
end
|
66
|
+
|
67
|
+
def platform_resolve_type_key(type)
|
68
|
+
"#{type.graphql_name}.resolve_type"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Tracing
|
5
|
+
module StatsdTrace
|
6
|
+
include PlatformTrace
|
7
|
+
|
8
|
+
# @param statsd [Object] A statsd client
|
9
|
+
def initialize(statsd:, **rest)
|
10
|
+
@statsd = statsd
|
11
|
+
super(**rest)
|
12
|
+
end
|
13
|
+
|
14
|
+
{
|
15
|
+
'lex' => "graphql.lex",
|
16
|
+
'parse' => "graphql.parse",
|
17
|
+
'validate' => "graphql.validate",
|
18
|
+
'analyze_query' => "graphql.analyze_query",
|
19
|
+
'analyze_multiplex' => "graphql.analyze_multiplex",
|
20
|
+
'execute_multiplex' => "graphql.execute_multiplex",
|
21
|
+
'execute_query' => "graphql.execute_query",
|
22
|
+
'execute_query_lazy' => "graphql.execute_query_lazy",
|
23
|
+
}.each do |trace_method, platform_key|
|
24
|
+
module_eval <<-RUBY, __FILE__, __LINE__
|
25
|
+
def #{trace_method}(**data)
|
26
|
+
@statsd.time("#{platform_key}") do
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
RUBY
|
31
|
+
end
|
32
|
+
|
33
|
+
def platform_execute_field(platform_key, &block)
|
34
|
+
@statsd.time(platform_key, &block)
|
35
|
+
end
|
36
|
+
|
37
|
+
def platform_authorized(key, &block)
|
38
|
+
@statsd.time(key, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
alias :platform_resolve_type :platform_authorized
|
42
|
+
|
43
|
+
def platform_field_key(field)
|
44
|
+
"graphql.#{field.path}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def platform_authorized_key(type)
|
48
|
+
"graphql.authorized.#{type.graphql_name}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def platform_resolve_type_key(type)
|
52
|
+
"graphql.resolve_type.#{type.graphql_name}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/graphql/tracing.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
# Legacy tracing:
|
2
3
|
require "graphql/tracing/active_support_notifications_tracing"
|
3
4
|
require "graphql/tracing/platform_tracing"
|
4
5
|
require "graphql/tracing/appoptics_tracing"
|
@@ -9,51 +10,147 @@ require "graphql/tracing/scout_tracing"
|
|
9
10
|
require "graphql/tracing/statsd_tracing"
|
10
11
|
require "graphql/tracing/prometheus_tracing"
|
11
12
|
|
13
|
+
# New Tracing:
|
14
|
+
require "graphql/tracing/platform_trace"
|
15
|
+
require "graphql/tracing/appoptics_trace"
|
16
|
+
require "graphql/tracing/appsignal_trace"
|
17
|
+
require "graphql/tracing/data_dog_trace"
|
18
|
+
require "graphql/tracing/new_relic_trace"
|
19
|
+
require "graphql/tracing/notifications_trace"
|
20
|
+
require "graphql/tracing/scout_trace"
|
21
|
+
require "graphql/tracing/statsd_trace"
|
22
|
+
require "graphql/tracing/prometheus_trace"
|
12
23
|
if defined?(PrometheusExporter::Server)
|
13
24
|
require "graphql/tracing/prometheus_tracing/graphql_collector"
|
14
25
|
end
|
15
26
|
|
16
27
|
module GraphQL
|
17
|
-
# Library entry point for performance metric reporting.
|
18
|
-
#
|
19
|
-
# @example Sending custom events
|
20
|
-
# query.trace("my_custom_event", { ... }) do
|
21
|
-
# # do stuff ...
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# @example Adding a tracer to a schema
|
25
|
-
# class MySchema < GraphQL::Schema
|
26
|
-
# tracer MyTracer # <= responds to .trace(key, data, &block)
|
27
|
-
# end
|
28
|
-
#
|
29
|
-
# @example Adding a tracer to a single query
|
30
|
-
# MySchema.execute(query_str, context: { backtrace: true })
|
31
|
-
#
|
32
|
-
# Events:
|
33
|
-
#
|
34
|
-
# Key | Metadata
|
35
|
-
# ----|---------
|
36
|
-
# lex | `{ query_string: String }`
|
37
|
-
# parse | `{ query_string: String }`
|
38
|
-
# validate | `{ query: GraphQL::Query, validate: Boolean }`
|
39
|
-
# analyze_multiplex | `{ multiplex: GraphQL::Execution::Multiplex }`
|
40
|
-
# analyze_query | `{ query: GraphQL::Query }`
|
41
|
-
# execute_multiplex | `{ multiplex: GraphQL::Execution::Multiplex }`
|
42
|
-
# execute_query | `{ query: GraphQL::Query }`
|
43
|
-
# execute_query_lazy | `{ query: GraphQL::Query?, multiplex: GraphQL::Execution::Multiplex? }`
|
44
|
-
# execute_field | `{ owner: Class, field: GraphQL::Schema::Field, query: GraphQL::Query, path: Array<String, Integer>, ast_node: GraphQL::Language::Nodes::Field}`
|
45
|
-
# execute_field_lazy | `{ owner: Class, field: GraphQL::Schema::Field, query: GraphQL::Query, path: Array<String, Integer>, ast_node: GraphQL::Language::Nodes::Field}`
|
46
|
-
# authorized | `{ context: GraphQL::Query::Context, type: Class, object: Object, path: Array<String, Integer> }`
|
47
|
-
# authorized_lazy | `{ context: GraphQL::Query::Context, type: Class, object: Object, path: Array<String, Integer> }`
|
48
|
-
# resolve_type | `{ context: GraphQL::Query::Context, type: Class, object: Object, path: Array<String, Integer> }`
|
49
|
-
# resolve_type_lazy | `{ context: GraphQL::Query::Context, type: Class, object: Object, path: Array<String, Integer> }`
|
50
|
-
#
|
51
|
-
# Note that `execute_field` and `execute_field_lazy` receive different data in different settings:
|
52
|
-
#
|
53
|
-
# - When using {GraphQL::Execution::Interpreter}, they receive `{field:, path:, query:}`
|
54
|
-
# - Otherwise, they receive `{context: ...}`
|
55
|
-
#
|
56
28
|
module Tracing
|
29
|
+
class Trace
|
30
|
+
# @param multiplex [GraphQL::Execution::Multiplex, nil]
|
31
|
+
# @param query [GraphQL::Query, nil]
|
32
|
+
def initialize(multiplex: nil, query: nil, **_options)
|
33
|
+
@multiplex = multiplex
|
34
|
+
@query = query
|
35
|
+
end
|
36
|
+
|
37
|
+
def lex(query_string:)
|
38
|
+
yield
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse(query_string:)
|
42
|
+
yield
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate(query:, validate:)
|
46
|
+
yield
|
47
|
+
end
|
48
|
+
|
49
|
+
def analyze_multiplex(multiplex:)
|
50
|
+
yield
|
51
|
+
end
|
52
|
+
|
53
|
+
def analyze_query(query:)
|
54
|
+
yield
|
55
|
+
end
|
56
|
+
|
57
|
+
def execute_multiplex(multiplex:)
|
58
|
+
yield
|
59
|
+
end
|
60
|
+
|
61
|
+
def execute_query(query:)
|
62
|
+
yield
|
63
|
+
end
|
64
|
+
|
65
|
+
def execute_query_lazy(query:, multiplex:)
|
66
|
+
yield
|
67
|
+
end
|
68
|
+
|
69
|
+
def execute_field(field:, query:, ast_node:, arguments:, object:)
|
70
|
+
yield
|
71
|
+
end
|
72
|
+
|
73
|
+
def execute_field_lazy(field:, query:, ast_node:, arguments:, object:)
|
74
|
+
yield
|
75
|
+
end
|
76
|
+
|
77
|
+
def authorized(query:, type:, object:)
|
78
|
+
yield
|
79
|
+
end
|
80
|
+
|
81
|
+
def authorized_lazy(query:, type:, object:)
|
82
|
+
yield
|
83
|
+
end
|
84
|
+
|
85
|
+
def resolve_type(query:, type:, object:)
|
86
|
+
yield
|
87
|
+
end
|
88
|
+
|
89
|
+
def resolve_type_lazy(query:, type:, object:)
|
90
|
+
yield
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
NullTrace = Trace.new
|
95
|
+
|
96
|
+
class LegacyTrace < Trace
|
97
|
+
def lex(query_string:, &block)
|
98
|
+
(@multiplex || @query).trace("lex", { query_string: query_string }, &block)
|
99
|
+
end
|
100
|
+
|
101
|
+
def parse(query_string:, &block)
|
102
|
+
(@multiplex || @query).trace("parse", { query_string: query_string }, &block)
|
103
|
+
end
|
104
|
+
|
105
|
+
def validate(query:, validate:, &block)
|
106
|
+
query.trace("validate", { validate: validate, query: query }, &block)
|
107
|
+
end
|
108
|
+
|
109
|
+
def analyze_multiplex(multiplex:, &block)
|
110
|
+
multiplex.trace("analyze_multiplex", { multiplex: multiplex }, &block)
|
111
|
+
end
|
112
|
+
|
113
|
+
def analyze_query(query:, &block)
|
114
|
+
query.trace("analyze_query", { query: query }, &block)
|
115
|
+
end
|
116
|
+
|
117
|
+
def execute_multiplex(multiplex:, &block)
|
118
|
+
multiplex.trace("execute_multiplex", { multiplex: multiplex }, &block)
|
119
|
+
end
|
120
|
+
|
121
|
+
def execute_query(query:, &block)
|
122
|
+
query.trace("execute_query", { query: query }, &block)
|
123
|
+
end
|
124
|
+
|
125
|
+
def execute_query_lazy(query:, multiplex:, &block)
|
126
|
+
multiplex.trace("execute_query_lazy", { multiplex: multiplex, query: query }, &block)
|
127
|
+
end
|
128
|
+
|
129
|
+
def execute_field(field:, query:, ast_node:, arguments:, object:, &block)
|
130
|
+
query.trace("execute_field", { field: field, query: query, ast_node: ast_node, arguments: arguments, object: object, owner: field.owner, path: query.context[:current_path] }, &block)
|
131
|
+
end
|
132
|
+
|
133
|
+
def execute_field_lazy(field:, query:, ast_node:, arguments:, object:, &block)
|
134
|
+
query.trace("execute_field_lazy", { field: field, query: query, ast_node: ast_node, arguments: arguments, object: object, owner: field.owner, path: query.context[:current_path] }, &block)
|
135
|
+
end
|
136
|
+
|
137
|
+
def authorized(query:, type:, object:, &block)
|
138
|
+
query.trace("authorized", { context: query.context, type: type, object: object, path: query.context[:current_path] }, &block)
|
139
|
+
end
|
140
|
+
|
141
|
+
def authorized_lazy(query:, type:, object:, &block)
|
142
|
+
query.trace("authorized_lazy", { context: query.context, type: type, object: object, path: query.context[:current_path] }, &block)
|
143
|
+
end
|
144
|
+
|
145
|
+
def resolve_type(query:, type:, object:, &block)
|
146
|
+
query.trace("resolve_type", { context: query.context, type: type, object: object, path: query.context[:current_path] }, &block)
|
147
|
+
end
|
148
|
+
|
149
|
+
def resolve_type_lazy(query:, type:, object:, &block)
|
150
|
+
query.trace("resolve_type_lazy", { context: query.context, type: type, object: object, path: query.context[:current_path] }, &block)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
57
154
|
# Objects may include traceable to gain a `.trace(...)` method.
|
58
155
|
# The object must have a `@tracers` ivar of type `Array<<#trace(k, d, &b)>>`.
|
59
156
|
# @api private
|
data/lib/graphql/type_kinds.rb
CHANGED
@@ -5,12 +5,13 @@ module GraphQL
|
|
5
5
|
# These objects are singletons, eg `GraphQL::TypeKinds::UNION`, `GraphQL::TypeKinds::SCALAR`.
|
6
6
|
class TypeKind
|
7
7
|
attr_reader :name, :description
|
8
|
-
def initialize(name, abstract: false, fields: false, wraps: false, input: false, description: nil)
|
8
|
+
def initialize(name, abstract: false, leaf: false, fields: false, wraps: false, input: false, description: nil)
|
9
9
|
@name = name
|
10
10
|
@abstract = abstract
|
11
11
|
@fields = fields
|
12
12
|
@wraps = wraps
|
13
13
|
@input = input
|
14
|
+
@leaf = leaf
|
14
15
|
@composite = fields? || abstract?
|
15
16
|
@description = description
|
16
17
|
end
|
@@ -27,6 +28,8 @@ module GraphQL
|
|
27
28
|
# Is this TypeKind a valid query input?
|
28
29
|
def input?; @input; end
|
29
30
|
def to_s; @name; end
|
31
|
+
# Is this TypeKind a primitive value?
|
32
|
+
def leaf?; @leaf; end
|
30
33
|
# Is this TypeKind composed of many values?
|
31
34
|
def composite?; @composite; end
|
32
35
|
|
@@ -64,11 +67,11 @@ module GraphQL
|
|
64
67
|
end
|
65
68
|
|
66
69
|
TYPE_KINDS = [
|
67
|
-
SCALAR = TypeKind.new("SCALAR", input: true, description: 'Indicates this type is a scalar.'),
|
70
|
+
SCALAR = TypeKind.new("SCALAR", input: true, leaf: true, description: 'Indicates this type is a scalar.'),
|
68
71
|
OBJECT = TypeKind.new("OBJECT", fields: true, description: 'Indicates this type is an object. `fields` and `interfaces` are valid fields.'),
|
69
72
|
INTERFACE = TypeKind.new("INTERFACE", abstract: true, fields: true, description: 'Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.'),
|
70
73
|
UNION = TypeKind.new("UNION", abstract: true, description: 'Indicates this type is a union. `possibleTypes` is a valid field.'),
|
71
|
-
ENUM = TypeKind.new("ENUM", input: true, description: 'Indicates this type is an enum. `enumValues` is a valid field.'),
|
74
|
+
ENUM = TypeKind.new("ENUM", input: true, leaf: true, description: 'Indicates this type is an enum. `enumValues` is a valid field.'),
|
72
75
|
INPUT_OBJECT = TypeKind.new("INPUT_OBJECT", input: true, description: 'Indicates this type is an input object. `inputFields` is a valid field.'),
|
73
76
|
LIST = TypeKind.new("LIST", wraps: true, description: 'Indicates this type is a list. `ofType` is a valid field.'),
|
74
77
|
NON_NULL = TypeKind.new("NON_NULL", wraps: true, description: 'Indicates this type is a non-null. `ofType` is a valid field.'),
|
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,
|
46
|
-
parse_with_racc(graphql_string,
|
45
|
+
def self.parse(graphql_string, trace: GraphQL::Tracing::NullTrace)
|
46
|
+
parse_with_racc(graphql_string, trace: trace)
|
47
47
|
end
|
48
48
|
|
49
49
|
# Read the contents of `filename` and parse them as GraphQL
|
@@ -54,18 +54,17 @@ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: http
|
|
54
54
|
parse_with_racc(content, filename: filename)
|
55
55
|
end
|
56
56
|
|
57
|
-
def self.parse_with_racc(string, filename: nil,
|
58
|
-
GraphQL::Language::Parser.parse(string, filename: filename,
|
57
|
+
def self.parse_with_racc(string, filename: nil, trace: GraphQL::Tracing::NullTrace)
|
58
|
+
GraphQL::Language::Parser.parse(string, filename: filename, trace: trace)
|
59
59
|
end
|
60
60
|
|
61
61
|
# @return [Array<GraphQL::Language::Token>]
|
62
62
|
def self.scan(graphql_string)
|
63
|
-
scan_with_ragel(graphql_string)
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.scan_with_ragel(graphql_string)
|
67
63
|
GraphQL::Language::Lexer.tokenize(graphql_string)
|
68
64
|
end
|
65
|
+
|
66
|
+
NOT_CONFIGURED = Object.new
|
67
|
+
private_constant :NOT_CONFIGURED
|
69
68
|
end
|
70
69
|
|
71
70
|
# Order matters for these:
|
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.0.
|
4
|
+
version: 2.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -317,6 +317,7 @@ files:
|
|
317
317
|
- lib/graphql/execution/multiplex.rb
|
318
318
|
- lib/graphql/execution_error.rb
|
319
319
|
- lib/graphql/filter.rb
|
320
|
+
- lib/graphql/graphql_ext.bundle
|
320
321
|
- lib/graphql/integer_decoding_error.rb
|
321
322
|
- lib/graphql/integer_encoding_error.rb
|
322
323
|
- lib/graphql/introspection.rb
|
@@ -341,7 +342,7 @@ files:
|
|
341
342
|
- lib/graphql/language/document_from_schema_definition.rb
|
342
343
|
- lib/graphql/language/generation.rb
|
343
344
|
- lib/graphql/language/lexer.rb
|
344
|
-
- lib/graphql/language/lexer.
|
345
|
+
- lib/graphql/language/lexer.ri
|
345
346
|
- lib/graphql/language/nodes.rb
|
346
347
|
- lib/graphql/language/parser.rb
|
347
348
|
- lib/graphql/language/parser.y
|
@@ -534,16 +535,26 @@ files:
|
|
534
535
|
- lib/graphql/subscriptions/instrumentation.rb
|
535
536
|
- lib/graphql/subscriptions/serialize.rb
|
536
537
|
- lib/graphql/tracing.rb
|
538
|
+
- lib/graphql/tracing/active_support_notifications_trace.rb
|
537
539
|
- lib/graphql/tracing/active_support_notifications_tracing.rb
|
540
|
+
- lib/graphql/tracing/appoptics_trace.rb
|
538
541
|
- lib/graphql/tracing/appoptics_tracing.rb
|
542
|
+
- lib/graphql/tracing/appsignal_trace.rb
|
539
543
|
- lib/graphql/tracing/appsignal_tracing.rb
|
544
|
+
- lib/graphql/tracing/data_dog_trace.rb
|
540
545
|
- lib/graphql/tracing/data_dog_tracing.rb
|
546
|
+
- lib/graphql/tracing/new_relic_trace.rb
|
541
547
|
- lib/graphql/tracing/new_relic_tracing.rb
|
548
|
+
- lib/graphql/tracing/notifications_trace.rb
|
542
549
|
- lib/graphql/tracing/notifications_tracing.rb
|
550
|
+
- lib/graphql/tracing/platform_trace.rb
|
543
551
|
- lib/graphql/tracing/platform_tracing.rb
|
552
|
+
- lib/graphql/tracing/prometheus_trace.rb
|
544
553
|
- lib/graphql/tracing/prometheus_tracing.rb
|
545
554
|
- lib/graphql/tracing/prometheus_tracing/graphql_collector.rb
|
555
|
+
- lib/graphql/tracing/scout_trace.rb
|
546
556
|
- lib/graphql/tracing/scout_tracing.rb
|
557
|
+
- lib/graphql/tracing/statsd_trace.rb
|
547
558
|
- lib/graphql/tracing/statsd_tracing.rb
|
548
559
|
- lib/graphql/type_kinds.rb
|
549
560
|
- lib/graphql/types.rb
|