graphql 2.0.25 → 2.0.27
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/generators/graphql/relay.rb +18 -1
- data/lib/graphql/language/lexer.rb +86 -56
- data/lib/graphql/language/parser.rb +706 -691
- data/lib/graphql/language/parser.y +1 -0
- data/lib/graphql/schema/addition.rb +6 -0
- data/lib/graphql/schema/field.rb +1 -1
- data/lib/graphql/schema/resolver.rb +10 -8
- data/lib/graphql/schema/validator.rb +1 -1
- data/lib/graphql/tracing/data_dog_trace.rb +35 -12
- data/lib/graphql/version.rb +1 -1
- metadata +2 -2
data/lib/graphql/schema/field.rb
CHANGED
@@ -92,7 +92,7 @@ module GraphQL
|
|
92
92
|
# @param resolver [Class] A {GraphQL::Schema::Resolver} class to use for field configuration
|
93
93
|
# @param mutation [Class] A {GraphQL::Schema::Mutation} class to use for field configuration
|
94
94
|
# @param subscription [Class] A {GraphQL::Schema::Subscription} class to use for field configuration
|
95
|
-
# @return [GraphQL::Schema:Field] an instance of `self
|
95
|
+
# @return [GraphQL::Schema:Field] an instance of `self`
|
96
96
|
# @see {.initialize} for other options
|
97
97
|
def self.from_options(name = nil, type = nil, desc = nil, resolver: nil, mutation: nil, subscription: nil,**kwargs, &block)
|
98
98
|
if (resolver_class = resolver || mutation || subscription)
|
@@ -65,19 +65,20 @@ module GraphQL
|
|
65
65
|
# @api private
|
66
66
|
def resolve_with_support(**args)
|
67
67
|
# First call the ready? hook which may raise
|
68
|
-
|
68
|
+
raw_ready_val = if args.any?
|
69
69
|
ready?(**args)
|
70
70
|
else
|
71
71
|
ready?
|
72
72
|
end
|
73
|
-
context.query.after_lazy(
|
74
|
-
if
|
73
|
+
context.query.after_lazy(raw_ready_val) do |ready_val|
|
74
|
+
if ready_val.is_a?(Array)
|
75
|
+
is_ready, ready_early_return = ready_val
|
75
76
|
if is_ready != false
|
76
77
|
raise "Unexpected result from #ready? (expected `true`, `false` or `[false, {...}]`): [#{is_ready.inspect}, #{ready_early_return.inspect}]"
|
77
78
|
else
|
78
79
|
ready_early_return
|
79
80
|
end
|
80
|
-
elsif
|
81
|
+
elsif ready_val
|
81
82
|
# Then call each prepare hook, which may return a different value
|
82
83
|
# for that argument, or may return a lazy object
|
83
84
|
load_arguments_val = load_arguments(args)
|
@@ -85,21 +86,22 @@ module GraphQL
|
|
85
86
|
@prepared_arguments = loaded_args
|
86
87
|
Schema::Validator.validate!(self.class.validators, object, context, loaded_args, as: @field)
|
87
88
|
# Then call `authorized?`, which may raise or may return a lazy object
|
88
|
-
|
89
|
+
raw_authorized_val = if loaded_args.any?
|
89
90
|
authorized?(**loaded_args)
|
90
91
|
else
|
91
92
|
authorized?
|
92
93
|
end
|
93
|
-
context.query.after_lazy(
|
94
|
+
context.query.after_lazy(raw_authorized_val) do |authorized_val|
|
94
95
|
# If the `authorized?` returned two values, `false, early_return`,
|
95
96
|
# then use the early return value instead of continuing
|
96
|
-
if
|
97
|
+
if authorized_val.is_a?(Array)
|
98
|
+
authorized_result, early_return = authorized_val
|
97
99
|
if authorized_result == false
|
98
100
|
early_return
|
99
101
|
else
|
100
102
|
raise "Unexpected result from #authorized? (expected `true`, `false` or `[false, {...}]`): [#{authorized_result.inspect}, #{early_return.inspect}]"
|
101
103
|
end
|
102
|
-
elsif
|
104
|
+
elsif authorized_val
|
103
105
|
# Finally, all the hooks have passed, so resolve it
|
104
106
|
if loaded_args.any?
|
105
107
|
public_send(self.class.resolve_method, **loaded_args)
|
@@ -133,7 +133,7 @@ module GraphQL
|
|
133
133
|
if all_errors.frozen? # It's empty
|
134
134
|
all_errors = []
|
135
135
|
end
|
136
|
-
interpolation_vars = { validated: validated.graphql_name }
|
136
|
+
interpolation_vars = { validated: validated.graphql_name, value: value.inspect }
|
137
137
|
if errors.is_a?(String)
|
138
138
|
all_errors << (errors % interpolation_vars)
|
139
139
|
else
|
@@ -76,7 +76,7 @@ module GraphQL
|
|
76
76
|
RUBY
|
77
77
|
end
|
78
78
|
|
79
|
-
def
|
79
|
+
def execute_field_span(span_key, query, field, ast_node, arguments, object)
|
80
80
|
return_type = field.type.unwrap
|
81
81
|
trace_field = if return_type.kind.scalar? || return_type.kind.enum?
|
82
82
|
(field.trace.nil? && @trace_scalars) || field.trace
|
@@ -99,18 +99,31 @@ module GraphQL
|
|
99
99
|
prepare_span_data = { query: query, field: field, ast_node: ast_node, arguments: arguments, object: object }
|
100
100
|
prepare_span(span_key, prepare_span_data, span)
|
101
101
|
end
|
102
|
-
|
102
|
+
yield
|
103
103
|
end
|
104
104
|
else
|
105
|
+
yield
|
106
|
+
end
|
107
|
+
end
|
108
|
+
def execute_field(query:, field:, ast_node:, arguments:, object:)
|
109
|
+
execute_field_span("execute_field", query, field, ast_node, arguments, object) do
|
105
110
|
super(query: query, field: field, ast_node: ast_node, arguments: arguments, object: object)
|
106
111
|
end
|
107
112
|
end
|
108
113
|
|
109
114
|
def execute_field_lazy(query:, field:, ast_node:, arguments:, object:)
|
110
|
-
|
115
|
+
execute_field_span("execute_field_lazy", query, field, ast_node, arguments, object) do
|
116
|
+
super(query: query, field: field, ast_node: ast_node, arguments: arguments, object: object)
|
117
|
+
end
|
111
118
|
end
|
112
119
|
|
113
|
-
def authorized(
|
120
|
+
def authorized(query:, type:, object:)
|
121
|
+
authorized_span("authorized", object, type, query) do
|
122
|
+
super(query: query, type: type, object: object)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def authorized_span(span_key, object, type, query)
|
114
127
|
platform_key = @platform_key_cache[DataDogTrace].platform_authorized_key_cache[type]
|
115
128
|
@tracer.trace(platform_key, service: @service_name) do |span|
|
116
129
|
span.span_type = 'custom'
|
@@ -121,15 +134,29 @@ module GraphQL
|
|
121
134
|
if @has_prepare_span
|
122
135
|
prepare_span(span_key, {object: object, type: type, query: query}, span)
|
123
136
|
end
|
137
|
+
yield
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def authorized_lazy(object:, type:, query:)
|
142
|
+
authorized_span("authorized_lazy", object, type, query) do
|
124
143
|
super(query: query, type: type, object: object)
|
125
144
|
end
|
126
145
|
end
|
127
146
|
|
128
|
-
def
|
129
|
-
|
147
|
+
def resolve_type(object:, type:, query:)
|
148
|
+
resolve_type_span("resolve_type", object, type, query) do
|
149
|
+
super(object: object, query: query, type: type)
|
150
|
+
end
|
130
151
|
end
|
131
152
|
|
132
|
-
def
|
153
|
+
def resolve_type_lazy(object:, type:, query:)
|
154
|
+
resolve_type_span("resolve_type_lazy", object, type, query) do
|
155
|
+
super(object: object, query: query, type: type)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def resolve_type_span(span_key, object, type, query)
|
133
160
|
platform_key = @platform_key_cache[DataDogTrace].platform_resolve_type_key_cache[type]
|
134
161
|
@tracer.trace(platform_key, service: @service_name) do |span|
|
135
162
|
span.span_type = 'custom'
|
@@ -140,14 +167,10 @@ module GraphQL
|
|
140
167
|
if @has_prepare_span
|
141
168
|
prepare_span(span_key, {object: object, type: type, query: query}, span)
|
142
169
|
end
|
143
|
-
|
170
|
+
yield
|
144
171
|
end
|
145
172
|
end
|
146
173
|
|
147
|
-
def resolve_type_lazy(**kwargs, &block)
|
148
|
-
resolve_type(span_key: "resolve_type_lazy", **kwargs, &block)
|
149
|
-
end
|
150
|
-
|
151
174
|
include PlatformTrace
|
152
175
|
|
153
176
|
# Implement this method in a subclass to apply custom tags to datadog spans
|
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.0.
|
4
|
+
version: 2.0.27
|
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-08-
|
11
|
+
date: 2023-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|