graphql 2.0.17.2 → 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/analysis/ast.rb +2 -2
- data/lib/graphql/backtrace/trace.rb +96 -0
- data/lib/graphql/backtrace/tracer.rb +1 -1
- 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/resolve.rb +19 -0
- data/lib/graphql/execution/interpreter/runtime.rb +254 -211
- data/lib/graphql/execution/interpreter.rb +9 -14
- data/lib/graphql/execution/lazy.rb +2 -4
- data/lib/graphql/execution/multiplex.rb +2 -1
- data/lib/graphql/filter.rb +7 -2
- data/lib/graphql/language/document_from_schema_definition.rb +25 -9
- data/lib/graphql/language/lexer.rb +216 -1505
- data/lib/graphql/language/nodes.rb +27 -9
- data/lib/graphql/language/parser.rb +509 -491
- data/lib/graphql/language/parser.y +43 -38
- data/lib/graphql/pagination/active_record_relation_connection.rb +0 -8
- data/lib/graphql/pagination/connection.rb +5 -5
- data/lib/graphql/query/context.rb +62 -31
- data/lib/graphql/query/null_context.rb +1 -1
- data/lib/graphql/query.rb +22 -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 +44 -31
- data/lib/graphql/schema/field_extension.rb +1 -4
- data/lib/graphql/schema/find_inherited_value.rb +2 -7
- data/lib/graphql/schema/member/base_dsl_methods.rb +13 -11
- data/lib/graphql/schema/member/has_arguments.rb +1 -1
- data/lib/graphql/schema/member/has_ast_node.rb +12 -0
- data/lib/graphql/schema/member/has_deprecation_reason.rb +3 -4
- data/lib/graphql/schema/member/has_directives.rb +15 -10
- data/lib/graphql/schema/member/has_fields.rb +87 -37
- data/lib/graphql/schema/member/has_validators.rb +2 -2
- data/lib/graphql/schema/member/relay_shortcuts.rb +19 -0
- data/lib/graphql/schema/member/type_system_helpers.rb +1 -1
- data/lib/graphql/schema/object.rb +2 -4
- data/lib/graphql/schema/resolver/has_payload_type.rb +9 -9
- data/lib/graphql/schema/resolver.rb +4 -4
- data/lib/graphql/schema/timeout.rb +24 -28
- data/lib/graphql/schema/validator.rb +1 -1
- data/lib/graphql/schema/warden.rb +11 -2
- data/lib/graphql/schema.rb +72 -1
- 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/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 +77 -0
- data/lib/graphql/tracing/data_dog_trace.rb +148 -0
- data/lib/graphql/tracing/legacy_trace.rb +65 -0
- data/lib/graphql/tracing/new_relic_trace.rb +75 -0
- data/lib/graphql/tracing/notifications_trace.rb +42 -0
- data/lib/graphql/tracing/platform_trace.rb +109 -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/graphql_collector.rb +1 -1
- 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/trace.rb +75 -0
- data/lib/graphql/tracing.rb +16 -39
- data/lib/graphql/type_kinds.rb +6 -3
- data/lib/graphql/types/relay/base_connection.rb +1 -1
- data/lib/graphql/types/relay/connection_behaviors.rb +24 -2
- data/lib/graphql/types/relay/edge_behaviors.rb +16 -2
- data/lib/graphql/types/relay/node_behaviors.rb +7 -1
- data/lib/graphql/types/relay/page_info_behaviors.rb +7 -2
- data/lib/graphql/types/relay.rb +0 -1
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +16 -9
- metadata +33 -8
- data/lib/graphql/language/lexer.rl +0 -280
- data/lib/graphql/types/relay/default_relay.rb +0 -27
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
|
data/lib/graphql/analysis/ast.rb
CHANGED
@@ -21,7 +21,7 @@ module GraphQL
|
|
21
21
|
def analyze_multiplex(multiplex, analyzers)
|
22
22
|
multiplex_analyzers = analyzers.map { |analyzer| analyzer.new(multiplex) }
|
23
23
|
|
24
|
-
multiplex.
|
24
|
+
multiplex.current_trace.analyze_multiplex(multiplex: multiplex) do
|
25
25
|
query_results = multiplex.queries.map do |query|
|
26
26
|
if query.valid?
|
27
27
|
analyze_query(
|
@@ -48,7 +48,7 @@ module GraphQL
|
|
48
48
|
# @param analyzers [Array<GraphQL::Analysis::AST::Analyzer>]
|
49
49
|
# @return [Array<Any>] Results from those analyzers
|
50
50
|
def analyze_query(query, analyzers, multiplex_analyzers: [])
|
51
|
-
query.
|
51
|
+
query.current_trace.analyze_query(query: query) do
|
52
52
|
query_analyzers = analyzers
|
53
53
|
.map { |analyzer| analyzer.new(query) }
|
54
54
|
.select { |analyzer| analyzer.analyze? }
|
@@ -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
|
@@ -25,7 +25,7 @@ module GraphQL
|
|
25
25
|
when "execute_field", "execute_field_lazy"
|
26
26
|
query = metadata[:query]
|
27
27
|
multiplex = query.multiplex
|
28
|
-
push_key =
|
28
|
+
push_key = query.context[:current_path]
|
29
29
|
parent_frame = multiplex.context[:graphql_backtrace_contexts][push_key[0..-2]]
|
30
30
|
|
31
31
|
if parent_frame.is_a?(GraphQL::Query)
|
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
|
@@ -11,6 +11,25 @@ module GraphQL
|
|
11
11
|
nil
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.resolve_each_depth(lazies_at_depth, dataloader)
|
15
|
+
depths = lazies_at_depth.keys
|
16
|
+
depths.sort!
|
17
|
+
next_depth = depths.first
|
18
|
+
if next_depth
|
19
|
+
lazies = lazies_at_depth[next_depth]
|
20
|
+
lazies_at_depth.delete(next_depth)
|
21
|
+
if lazies.any?
|
22
|
+
dataloader.append_job {
|
23
|
+
lazies.each(&:value) # resolve these Lazy instances
|
24
|
+
}
|
25
|
+
# Run lazies _and_ dataloader, see if more are enqueued
|
26
|
+
dataloader.run
|
27
|
+
resolve_each_depth(lazies_at_depth, dataloader)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
14
33
|
# After getting `results` back from an interpreter evaluation,
|
15
34
|
# continue it until you get a response-ready Ruby value.
|
16
35
|
#
|