graphql 2.0.20 → 2.0.22
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/backtrace/trace.rb +96 -0
- data/lib/graphql/backtrace.rb +6 -1
- data/lib/graphql/execution/interpreter/arguments.rb +1 -1
- data/lib/graphql/execution/interpreter/arguments_cache.rb +33 -33
- data/lib/graphql/execution/interpreter/runtime.rb +274 -209
- data/lib/graphql/execution/interpreter.rb +2 -3
- data/lib/graphql/execution/lookahead.rb +1 -1
- data/lib/graphql/filter.rb +8 -2
- data/lib/graphql/language/document_from_schema_definition.rb +37 -17
- data/lib/graphql/language/lexer.rb +5 -3
- data/lib/graphql/language/nodes.rb +2 -2
- data/lib/graphql/language/parser.rb +475 -458
- data/lib/graphql/language/parser.y +5 -1
- data/lib/graphql/pagination/connection.rb +5 -5
- data/lib/graphql/query/context.rb +22 -12
- data/lib/graphql/query/null_context.rb +4 -1
- data/lib/graphql/query.rb +25 -11
- data/lib/graphql/schema/argument.rb +12 -14
- data/lib/graphql/schema/build_from_definition.rb +15 -3
- data/lib/graphql/schema/enum_value.rb +2 -5
- data/lib/graphql/schema/field/connection_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +17 -16
- data/lib/graphql/schema/field_extension.rb +1 -4
- data/lib/graphql/schema/find_inherited_value.rb +2 -7
- data/lib/graphql/schema/input_object.rb +1 -1
- data/lib/graphql/schema/member/has_arguments.rb +10 -8
- data/lib/graphql/schema/member/has_directives.rb +4 -6
- data/lib/graphql/schema/member/has_fields.rb +80 -36
- data/lib/graphql/schema/member/has_validators.rb +2 -2
- data/lib/graphql/schema/object.rb +1 -1
- data/lib/graphql/schema/printer.rb +3 -1
- data/lib/graphql/schema/relay_classic_mutation.rb +1 -1
- data/lib/graphql/schema/resolver.rb +8 -8
- data/lib/graphql/schema/validator.rb +1 -1
- data/lib/graphql/schema/warden.rb +11 -3
- data/lib/graphql/schema.rb +41 -12
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +12 -4
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +2 -2
- data/lib/graphql/tracing/appsignal_trace.rb +6 -0
- data/lib/graphql/tracing/legacy_trace.rb +65 -0
- data/lib/graphql/tracing/notifications_trace.rb +5 -1
- data/lib/graphql/tracing/platform_trace.rb +21 -19
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +1 -1
- data/lib/graphql/tracing/trace.rb +75 -0
- data/lib/graphql/tracing.rb +4 -123
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +4 -0
- data/readme.md +1 -1
- metadata +6 -3
@@ -14,7 +14,7 @@ module GraphQL
|
|
14
14
|
class << self
|
15
15
|
# Used internally to signal that the query shouldn't be executed
|
16
16
|
# @api private
|
17
|
-
NO_OPERATION =
|
17
|
+
NO_OPERATION = GraphQL::EmptyObjects::EMPTY_HASH
|
18
18
|
|
19
19
|
# @param schema [GraphQL::Schema]
|
20
20
|
# @param queries [Array<GraphQL::Query, Hash>]
|
@@ -87,7 +87,6 @@ module GraphQL
|
|
87
87
|
|
88
88
|
# Then, work through lazy results in a breadth-first way
|
89
89
|
multiplex.dataloader.append_job {
|
90
|
-
tracer = multiplex
|
91
90
|
query = multiplex.queries.length == 1 ? multiplex.queries[0] : nil
|
92
91
|
queries = multiplex ? multiplex.queries : [query]
|
93
92
|
final_values = queries.map do |query|
|
@@ -96,7 +95,7 @@ module GraphQL
|
|
96
95
|
runtime ? runtime.final_result : nil
|
97
96
|
end
|
98
97
|
final_values.compact!
|
99
|
-
|
98
|
+
multiplex.current_trace.execute_query_lazy(multiplex: multiplex, query: query) do
|
100
99
|
Interpreter::Resolve.resolve_each_depth(lazies_at_depth, multiplex.dataloader)
|
101
100
|
end
|
102
101
|
queries.each do |query|
|
@@ -55,7 +55,7 @@ module GraphQL
|
|
55
55
|
@arguments
|
56
56
|
else
|
57
57
|
@arguments = if @field
|
58
|
-
@query.
|
58
|
+
@query.after_lazy(@query.arguments_for(@ast_nodes.first, @field)) do |args|
|
59
59
|
args.is_a?(Execution::Interpreter::Arguments) ? args.keyword_arguments : args
|
60
60
|
end
|
61
61
|
else
|
data/lib/graphql/filter.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require "graphql/deprecation"
|
3
|
+
|
2
4
|
module GraphQL
|
3
5
|
# @api private
|
4
6
|
class Filter
|
5
|
-
def initialize(only: nil, except: nil)
|
7
|
+
def initialize(only: nil, except: nil, silence_deprecation_warning: false)
|
8
|
+
if !silence_deprecation_warning
|
9
|
+
line = caller(2, 10).find { |l| !l.include?("lib/graphql") }
|
10
|
+
GraphQL::Deprecation.warn("GraphQL::Filter, `only:`, `except:`, and `.merge_filters` are deprecated and will be removed in v2.1.0. Implement `visible?` on your schema members instead (https://graphql-ruby.org/authorization/visibility.html).\n #{line}")
|
11
|
+
end
|
6
12
|
@only = only
|
7
13
|
@except = except
|
8
14
|
end
|
@@ -17,7 +23,7 @@ module GraphQL
|
|
17
23
|
onlies = [self].concat(Array(only))
|
18
24
|
merged_only = MergedOnly.build(onlies)
|
19
25
|
merged_except = MergedExcept.build(Array(except))
|
20
|
-
self.class.new(only: merged_only, except: merged_except)
|
26
|
+
self.class.new(only: merged_only, except: merged_except, silence_deprecation_warning: true)
|
21
27
|
end
|
22
28
|
|
23
29
|
private
|
@@ -22,18 +22,23 @@ module GraphQL
|
|
22
22
|
@include_introspection_types = include_introspection_types
|
23
23
|
@include_built_in_scalars = include_built_in_scalars
|
24
24
|
@include_built_in_directives = include_built_in_directives
|
25
|
+
@include_one_of = false
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
schema_context = schema.context_class.new(query: nil, object: nil, schema: schema, values: context)
|
28
|
+
|
29
|
+
@warden = if only || except
|
30
|
+
filter = GraphQL::Filter
|
31
|
+
.new(only: only, except: except)
|
32
|
+
.merge(only: @schema.method(:visible?))
|
33
|
+
GraphQL::Schema::Warden.new(
|
34
|
+
filter,
|
35
|
+
schema: @schema,
|
36
|
+
context: schema_context,
|
37
|
+
)
|
38
|
+
else
|
39
|
+
GraphQL::Schema::Warden.new(schema: @schema, context: schema_context)
|
29
40
|
end
|
30
41
|
|
31
|
-
schema_context = schema.context_class.new(query: nil, object: nil, schema: schema, values: context)
|
32
|
-
@warden = GraphQL::Schema::Warden.new(
|
33
|
-
filter,
|
34
|
-
schema: @schema,
|
35
|
-
context: schema_context,
|
36
|
-
)
|
37
42
|
schema_context.warden = @warden
|
38
43
|
end
|
39
44
|
|
@@ -245,20 +250,30 @@ module GraphQL
|
|
245
250
|
end
|
246
251
|
|
247
252
|
def build_directive_nodes(directives)
|
248
|
-
if !include_built_in_directives
|
249
|
-
directives = directives.reject { |directive| directive.default_directive? }
|
250
|
-
end
|
251
|
-
|
252
253
|
directives
|
253
254
|
.map { |directive| build_directive_node(directive) }
|
254
255
|
.sort_by(&:name)
|
255
256
|
end
|
256
257
|
|
257
258
|
def build_definition_nodes
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
259
|
+
dirs_to_build = warden.directives
|
260
|
+
if !include_built_in_directives
|
261
|
+
dirs_to_build = dirs_to_build.reject { |directive| directive.default_directive? }
|
262
|
+
end
|
263
|
+
dir_nodes = build_directive_nodes(dirs_to_build)
|
264
|
+
|
265
|
+
type_nodes = build_type_definition_nodes(warden.reachable_types)
|
266
|
+
|
267
|
+
if @include_one_of
|
268
|
+
# This may have been set to true when iterating over all types
|
269
|
+
dir_nodes.concat(build_directive_nodes([GraphQL::Schema::Directive::OneOf]))
|
270
|
+
end
|
271
|
+
|
272
|
+
definitions = [*dir_nodes, *type_nodes]
|
273
|
+
if include_schema_node?
|
274
|
+
definitions.unshift(build_schema_node)
|
275
|
+
end
|
276
|
+
|
262
277
|
definitions
|
263
278
|
end
|
264
279
|
|
@@ -318,6 +333,11 @@ module GraphQL
|
|
318
333
|
)
|
319
334
|
end
|
320
335
|
end
|
336
|
+
|
337
|
+
# If this schema uses this built-in directive definition,
|
338
|
+
# include it in the print-out since it's not part of the spec yet.
|
339
|
+
@include_one_of ||= dir.class == GraphQL::Schema::Directive::OneOf
|
340
|
+
|
321
341
|
GraphQL::Language::Nodes::Directive.new(
|
322
342
|
name: dir.class.graphql_name,
|
323
343
|
arguments: args
|
@@ -95,12 +95,14 @@ module GraphQL
|
|
95
95
|
previous_token: nil,
|
96
96
|
}
|
97
97
|
|
98
|
-
|
99
|
-
|
98
|
+
value = string.dup.force_encoding(Encoding::UTF_8)
|
99
|
+
|
100
|
+
unless value.valid_encoding?
|
101
|
+
emit(:BAD_UNICODE_ESCAPE, 0, 0, meta, value)
|
100
102
|
return meta[:tokens]
|
101
103
|
end
|
102
104
|
|
103
|
-
scan = StringScanner.new
|
105
|
+
scan = StringScanner.new value
|
104
106
|
|
105
107
|
while !scan.eos?
|
106
108
|
pos = scan.pos
|
@@ -2,7 +2,7 @@
|
|
2
2
|
module GraphQL
|
3
3
|
module Language
|
4
4
|
module Nodes
|
5
|
-
NONE =
|
5
|
+
NONE = GraphQL::EmptyObjects::EMPTY_ARRAY
|
6
6
|
# {AbstractNode} is the base class for all nodes in a GraphQL AST.
|
7
7
|
#
|
8
8
|
# It provides some APIs for working with ASTs:
|
@@ -51,7 +51,7 @@ module GraphQL
|
|
51
51
|
other.children == self.children
|
52
52
|
end
|
53
53
|
|
54
|
-
NO_CHILDREN =
|
54
|
+
NO_CHILDREN = GraphQL::EmptyObjects::EMPTY_ARRAY
|
55
55
|
|
56
56
|
# @return [Array<GraphQL::Language::Nodes::AbstractNode>] all nodes in the tree below this one
|
57
57
|
def children
|