graphql 1.11.0 → 1.11.1
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 +4 -4
- data/lib/graphql.rb +3 -3
- data/lib/graphql/execution/interpreter/runtime.rb +3 -2
- data/lib/graphql/invalid_null_error.rb +18 -0
- data/lib/graphql/schema/field.rb +10 -1
- data/lib/graphql/schema/object.rb +1 -1
- data/lib/graphql/tracing.rb +1 -0
- data/lib/graphql/tracing/platform_tracing.rb +25 -15
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b152fd76301d994c8a685bce0539e409739c6e1e303c611c34a6424b2d2e68e
|
4
|
+
data.tar.gz: 84215fce3790161bebfa183e05b69abe6394396bec177ce69f98e5a53484d7b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83d130c2cd4c76f9869d60e4a32f80e2a20a3ff5c614e6852686c1d06d2da8b454065b5c382099877c2449e77f938f8ef5e2dfd69e22bf5a505e04a3edb8db2d
|
7
|
+
data.tar.gz: 06bf9038ca1f32d03fc4a0fc2ed6763420ff58d7c7b4aaad38a703b0eb090c3a35fb829c2a7e13420c1507ea8013e5d7084067c733de98b416698ea39ba46ba3
|
data/lib/graphql.rb
CHANGED
@@ -91,13 +91,13 @@ require "graphql/analysis"
|
|
91
91
|
require "graphql/tracing"
|
92
92
|
require "graphql/dig"
|
93
93
|
require "graphql/execution"
|
94
|
+
require "graphql/runtime_type_error"
|
95
|
+
require "graphql/unresolved_type_error"
|
96
|
+
require "graphql/invalid_null_error"
|
94
97
|
require "graphql/schema"
|
95
98
|
require "graphql/query"
|
96
99
|
require "graphql/directive"
|
97
100
|
require "graphql/execution"
|
98
|
-
require "graphql/runtime_type_error"
|
99
|
-
require "graphql/unresolved_type_error"
|
100
|
-
require "graphql/invalid_null_error"
|
101
101
|
require "graphql/types"
|
102
102
|
require "graphql/relay"
|
103
103
|
require "graphql/boolean_type"
|
@@ -254,7 +254,8 @@ module GraphQL
|
|
254
254
|
def continue_value(path, value, field, is_non_null, ast_node)
|
255
255
|
if value.nil?
|
256
256
|
if is_non_null
|
257
|
-
|
257
|
+
parent_type = field.owner_type
|
258
|
+
err = parent_type::InvalidNullError.new(parent_type, field, value)
|
258
259
|
write_invalid_null_in_response(path, err)
|
259
260
|
else
|
260
261
|
write_in_response(path, nil)
|
@@ -311,7 +312,7 @@ module GraphQL
|
|
311
312
|
possible_types = query.possible_types(type)
|
312
313
|
|
313
314
|
if !possible_types.include?(resolved_type)
|
314
|
-
parent_type = field.
|
315
|
+
parent_type = field.owner_type
|
315
316
|
err_class = type::UnresolvedTypeError
|
316
317
|
type_error = err_class.new(resolved_value, field, parent_type, resolved_type, possible_types)
|
317
318
|
schema.type_error(type_error, context)
|
@@ -28,5 +28,23 @@ module GraphQL
|
|
28
28
|
def parent_error?
|
29
29
|
false
|
30
30
|
end
|
31
|
+
|
32
|
+
class << self
|
33
|
+
attr_accessor :parent_class
|
34
|
+
|
35
|
+
def subclass_for(parent_class)
|
36
|
+
subclass = Class.new(self)
|
37
|
+
subclass.parent_class = parent_class
|
38
|
+
subclass
|
39
|
+
end
|
40
|
+
|
41
|
+
def inspect
|
42
|
+
if name.nil? && parent_class.respond_to?(:mutation) && (mutation = parent_class.mutation)
|
43
|
+
"#{mutation.inspect}::#{parent_class.graphql_name}::InvalidNullError"
|
44
|
+
else
|
45
|
+
super
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
31
49
|
end
|
32
50
|
end
|
data/lib/graphql/schema/field.rb
CHANGED
@@ -36,9 +36,18 @@ module GraphQL
|
|
36
36
|
# @return [Symbol] The method on the type to look up
|
37
37
|
attr_reader :resolver_method
|
38
38
|
|
39
|
-
# @return [Class] The
|
39
|
+
# @return [Class] The thing this field was defined on (type, mutation, resolver)
|
40
40
|
attr_accessor :owner
|
41
41
|
|
42
|
+
# @return [Class] The GraphQL type this field belongs to. (For fields defined on mutations, it's the payload type)
|
43
|
+
def owner_type
|
44
|
+
@owner_type ||= if owner < GraphQL::Schema::Mutation
|
45
|
+
owner.payload_type
|
46
|
+
else
|
47
|
+
owner
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
42
51
|
# @return [Symbol] the original name of the field, passed in by the user
|
43
52
|
attr_reader :original_name
|
44
53
|
|
@@ -74,7 +74,7 @@ module GraphQL
|
|
74
74
|
# Set up a type-specific invalid null error to use when this object's non-null fields wrongly return `nil`.
|
75
75
|
# It should help with debugging and bug tracker integrations.
|
76
76
|
def inherited(child_class)
|
77
|
-
child_class.const_set(:InvalidNullError,
|
77
|
+
child_class.const_set(:InvalidNullError, GraphQL::InvalidNullError.subclass_for(child_class))
|
78
78
|
super
|
79
79
|
end
|
80
80
|
|
data/lib/graphql/tracing.rb
CHANGED
@@ -7,6 +7,7 @@ require "graphql/tracing/data_dog_tracing"
|
|
7
7
|
require "graphql/tracing/new_relic_tracing"
|
8
8
|
require "graphql/tracing/scout_tracing"
|
9
9
|
require "graphql/tracing/skylight_tracing"
|
10
|
+
require "graphql/tracing/statsd_tracing"
|
10
11
|
require "graphql/tracing/prometheus_tracing"
|
11
12
|
|
12
13
|
if defined?(PrometheusExporter::Server)
|
@@ -32,17 +32,19 @@ module GraphQL
|
|
32
32
|
trace_field = true # implemented with instrumenter
|
33
33
|
else
|
34
34
|
field = data[:field]
|
35
|
-
cache = platform_key_cache(data.fetch(:query).context)
|
36
|
-
platform_key = cache.fetch(field) do
|
37
|
-
cache[field] = platform_field_key(data[:owner], field)
|
38
|
-
end
|
39
|
-
|
40
35
|
return_type = field.type.unwrap
|
41
36
|
trace_field = if return_type.kind.scalar? || return_type.kind.enum?
|
42
37
|
(field.trace.nil? && @trace_scalars) || field.trace
|
43
38
|
else
|
44
39
|
true
|
45
40
|
end
|
41
|
+
|
42
|
+
platform_key = if trace_field
|
43
|
+
context = data.fetch(:query).context
|
44
|
+
cached_platform_key(context, field) { platform_field_key(data[:owner], field) }
|
45
|
+
else
|
46
|
+
nil
|
47
|
+
end
|
46
48
|
end
|
47
49
|
|
48
50
|
if platform_key && trace_field
|
@@ -53,20 +55,16 @@ module GraphQL
|
|
53
55
|
yield
|
54
56
|
end
|
55
57
|
when "authorized", "authorized_lazy"
|
56
|
-
cache = platform_key_cache(data.fetch(:context))
|
57
58
|
type = data.fetch(:type)
|
58
|
-
|
59
|
-
|
60
|
-
end
|
59
|
+
context = data.fetch(:context)
|
60
|
+
platform_key = cached_platform_key(context, type) { platform_authorized_key(type) }
|
61
61
|
platform_trace(platform_key, key, data) do
|
62
62
|
yield
|
63
63
|
end
|
64
64
|
when "resolve_type", "resolve_type_lazy"
|
65
|
-
cache = platform_key_cache(data.fetch(:context))
|
66
65
|
type = data.fetch(:type)
|
67
|
-
|
68
|
-
|
69
|
-
end
|
66
|
+
context = data.fetch(:context)
|
67
|
+
platform_key = cached_platform_key(context, type) { platform_resolve_type_key(type) }
|
70
68
|
platform_trace(platform_key, key, data) do
|
71
69
|
yield
|
72
70
|
end
|
@@ -119,8 +117,20 @@ module GraphQL
|
|
119
117
|
|
120
118
|
attr_reader :options
|
121
119
|
|
122
|
-
|
123
|
-
|
120
|
+
# Different kind of schema objects have different kinds of keys:
|
121
|
+
#
|
122
|
+
# - Object types: `.authorized`
|
123
|
+
# - Union/Interface types: `.resolve_type`
|
124
|
+
# - Fields: execution
|
125
|
+
#
|
126
|
+
# So, they can all share one cache.
|
127
|
+
#
|
128
|
+
# If the key isn't present, the given block is called and the result is cached for `key`.
|
129
|
+
#
|
130
|
+
# @return [String]
|
131
|
+
def cached_platform_key(ctx, key)
|
132
|
+
cache = ctx.namespace(self.class)[:platform_key_cache] ||= {}
|
133
|
+
cache.fetch(key) { cache[key] = yield }
|
124
134
|
end
|
125
135
|
end
|
126
136
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Tracing
|
5
|
+
class StatsdTracing < 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_multiplex' => "graphql.execute_multiplex",
|
13
|
+
'execute_query' => "graphql.execute_query",
|
14
|
+
'execute_query_lazy' => "graphql.execute_query_lazy",
|
15
|
+
}
|
16
|
+
|
17
|
+
# @param statsd [Object] A statsd client
|
18
|
+
def initialize(statsd:, **rest)
|
19
|
+
@statsd = statsd
|
20
|
+
super(**rest)
|
21
|
+
end
|
22
|
+
|
23
|
+
def platform_trace(platform_key, key, data)
|
24
|
+
@statsd.time(platform_key) do
|
25
|
+
yield
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def platform_field_key(type, field)
|
30
|
+
"graphql.#{type.graphql_name}.#{field.graphql_name}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def platform_authorized_key(type)
|
34
|
+
"graphql.authorized.#{type.graphql_name}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def platform_resolve_type_key(type)
|
38
|
+
"graphql.resolve_type.#{type.graphql_name}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
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: 1.11.
|
4
|
+
version: 1.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -698,6 +698,7 @@ files:
|
|
698
698
|
- lib/graphql/tracing/prometheus_tracing/graphql_collector.rb
|
699
699
|
- lib/graphql/tracing/scout_tracing.rb
|
700
700
|
- lib/graphql/tracing/skylight_tracing.rb
|
701
|
+
- lib/graphql/tracing/statsd_tracing.rb
|
701
702
|
- lib/graphql/type_kinds.rb
|
702
703
|
- lib/graphql/types.rb
|
703
704
|
- lib/graphql/types/big_int.rb
|