graphql 2.0.20 → 2.0.21
Sign up to get free protection for your applications and to get access to all the features.
- 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 +2 -3
- data/lib/graphql/execution/interpreter/runtime.rb +200 -161
- data/lib/graphql/execution/interpreter.rb +1 -1
- data/lib/graphql/filter.rb +7 -2
- data/lib/graphql/language/document_from_schema_definition.rb +25 -9
- 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 +13 -12
- data/lib/graphql/query/null_context.rb +1 -1
- data/lib/graphql/query.rb +9 -5
- data/lib/graphql/schema/argument.rb +7 -9
- data/lib/graphql/schema/build_from_definition.rb +15 -3
- data/lib/graphql/schema/enum_value.rb +2 -5
- data/lib/graphql/schema/field.rb +14 -13
- data/lib/graphql/schema/field_extension.rb +1 -4
- data/lib/graphql/schema/find_inherited_value.rb +2 -7
- data/lib/graphql/schema/member/has_arguments.rb +1 -1
- 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/resolver.rb +4 -4
- data/lib/graphql/schema/validator.rb +1 -1
- data/lib/graphql/schema/warden.rb +3 -1
- data/lib/graphql/schema.rb +40 -11
- 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 +2 -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 +3 -123
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +4 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43f1cc3ef36a54a31f8afa03ee3109b34f046e26c427acfb80599a2dd245cf14
|
4
|
+
data.tar.gz: 4e4a15c766650e36004175de15cfcb9f67c6b4e7d24e2f91712a6ad3f8681453
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 908f3790bcc773bb6c7fe3db1f5e2ccabf361ece7b462b80fc4e59911167eabb8baf544739f31ac425579bca61b56b46937ac60e7a54a03827228016457388de
|
7
|
+
data.tar.gz: 62fb9dc90ab55aff66d3d1621fc28b18c0c9599e2f8a7f8521d372a6f549c85ac0a2e50a0d43cb77bde728cb44f85b178bb37388c6bd3d2aed5f8e91723a79ef
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
class Backtrace
|
4
|
+
module Trace
|
5
|
+
def validate(query:, validate:)
|
6
|
+
if query.multiplex
|
7
|
+
push_query_backtrace_context(query)
|
8
|
+
end
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def analyze_query(query:)
|
13
|
+
if query.multiplex # missing for stand-alone static validation
|
14
|
+
push_query_backtrace_context(query)
|
15
|
+
end
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute_query(query:)
|
20
|
+
push_query_backtrace_context(query)
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute_query_lazy(query:, multiplex:)
|
25
|
+
query ||= multiplex.queries.first
|
26
|
+
push_query_backtrace_context(query)
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def execute_field(field:, query:, ast_node:, arguments:, object:)
|
31
|
+
push_field_backtrace_context(field, query, ast_node, arguments, object)
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def execute_field_lazy(field:, query:, ast_node:, arguments:, object:)
|
36
|
+
push_field_backtrace_context(field, query, ast_node, arguments, object)
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
def execute_multiplex(multiplex:)
|
41
|
+
super
|
42
|
+
rescue StandardError => err
|
43
|
+
# This is an unhandled error from execution,
|
44
|
+
# Re-raise it with a GraphQL trace.
|
45
|
+
multiplex_context = multiplex.context
|
46
|
+
potential_context = multiplex_context[:last_graphql_backtrace_context]
|
47
|
+
|
48
|
+
if potential_context.is_a?(GraphQL::Query::Context) ||
|
49
|
+
potential_context.is_a?(Backtrace::Frame)
|
50
|
+
raise TracedError.new(err, potential_context)
|
51
|
+
else
|
52
|
+
raise
|
53
|
+
end
|
54
|
+
ensure
|
55
|
+
multiplex_context = multiplex.context
|
56
|
+
multiplex_context.delete(:graphql_backtrace_contexts)
|
57
|
+
multiplex_context.delete(:last_graphql_backtrace_context)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def push_query_backtrace_context(query)
|
63
|
+
push_data = query
|
64
|
+
multiplex = query.multiplex
|
65
|
+
push_key = []
|
66
|
+
push_storage = multiplex.context[:graphql_backtrace_contexts] ||= {}
|
67
|
+
push_storage[push_key] = push_data
|
68
|
+
multiplex.context[:last_graphql_backtrace_context] = push_data
|
69
|
+
end
|
70
|
+
|
71
|
+
def push_field_backtrace_context(field, query, ast_node, arguments, object)
|
72
|
+
multiplex = query.multiplex
|
73
|
+
push_key = query.context[:current_path]
|
74
|
+
push_storage = multiplex.context[:graphql_backtrace_contexts]
|
75
|
+
parent_frame = push_storage[push_key[0..-2]]
|
76
|
+
|
77
|
+
if parent_frame.is_a?(GraphQL::Query)
|
78
|
+
parent_frame = parent_frame.context
|
79
|
+
end
|
80
|
+
|
81
|
+
push_data = Frame.new(
|
82
|
+
query: query,
|
83
|
+
path: push_key,
|
84
|
+
ast_node: ast_node,
|
85
|
+
field: field,
|
86
|
+
object: object,
|
87
|
+
arguments: arguments,
|
88
|
+
parent_frame: parent_frame,
|
89
|
+
)
|
90
|
+
|
91
|
+
push_storage[push_key] = push_data
|
92
|
+
multiplex.context[:last_graphql_backtrace_context] = push_data
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/graphql/backtrace.rb
CHANGED
@@ -3,6 +3,7 @@ require "graphql/backtrace/inspect_result"
|
|
3
3
|
require "graphql/backtrace/table"
|
4
4
|
require "graphql/backtrace/traced_error"
|
5
5
|
require "graphql/backtrace/tracer"
|
6
|
+
require "graphql/backtrace/trace"
|
6
7
|
module GraphQL
|
7
8
|
# Wrap unhandled errors with {TracedError}.
|
8
9
|
#
|
@@ -23,7 +24,7 @@ module GraphQL
|
|
23
24
|
def_delegators :to_a, :each, :[]
|
24
25
|
|
25
26
|
def self.use(schema_defn)
|
26
|
-
schema_defn.
|
27
|
+
schema_defn.trace_with(self::Trace)
|
27
28
|
end
|
28
29
|
|
29
30
|
def initialize(context, value: nil)
|
@@ -54,5 +55,9 @@ module GraphQL
|
|
54
55
|
@parent_frame = parent_frame
|
55
56
|
end
|
56
57
|
end
|
58
|
+
|
59
|
+
class DefaultBacktraceTrace < GraphQL::Tracing::Trace
|
60
|
+
include GraphQL::Backtrace::Trace
|
61
|
+
end
|
57
62
|
end
|
58
63
|
end
|
@@ -55,9 +55,8 @@ module GraphQL
|
|
55
55
|
|
56
56
|
private
|
57
57
|
|
58
|
-
NO_ARGUMENTS =
|
59
|
-
|
60
|
-
NO_VALUE_GIVEN = Object.new
|
58
|
+
NO_ARGUMENTS = GraphQL::EmptyObjects::EMPTY_HASH
|
59
|
+
NO_VALUE_GIVEN = NOT_CONFIGURED
|
61
60
|
|
62
61
|
def self.prepare_args_hash(query, ast_arg_or_hash_or_value)
|
63
62
|
case ast_arg_or_hash_or_value
|