graphql 2.0.27 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/graphql/install/templates/base_mutation.erb +2 -0
- data/lib/generators/graphql/install/templates/mutation_type.erb +2 -0
- data/lib/generators/graphql/install_generator.rb +3 -0
- data/lib/generators/graphql/templates/base_argument.erb +2 -0
- data/lib/generators/graphql/templates/base_connection.erb +2 -0
- data/lib/generators/graphql/templates/base_edge.erb +2 -0
- data/lib/generators/graphql/templates/base_enum.erb +2 -0
- data/lib/generators/graphql/templates/base_field.erb +2 -0
- data/lib/generators/graphql/templates/base_input_object.erb +2 -0
- data/lib/generators/graphql/templates/base_interface.erb +2 -0
- data/lib/generators/graphql/templates/base_object.erb +2 -0
- data/lib/generators/graphql/templates/base_resolver.erb +6 -0
- data/lib/generators/graphql/templates/base_scalar.erb +2 -0
- data/lib/generators/graphql/templates/base_union.erb +2 -0
- data/lib/generators/graphql/templates/graphql_controller.erb +2 -0
- data/lib/generators/graphql/templates/loader.erb +2 -0
- data/lib/generators/graphql/templates/mutation.erb +2 -0
- data/lib/generators/graphql/templates/node_type.erb +2 -0
- data/lib/generators/graphql/templates/query_type.erb +2 -0
- data/lib/generators/graphql/templates/schema.erb +2 -0
- data/lib/graphql/analysis/ast/analyzer.rb +7 -0
- data/lib/graphql/analysis/ast/field_usage.rb +32 -7
- data/lib/graphql/analysis/ast/query_complexity.rb +80 -128
- data/lib/graphql/analysis/ast/query_depth.rb +7 -2
- data/lib/graphql/analysis/ast/visitor.rb +2 -2
- data/lib/graphql/analysis/ast.rb +21 -11
- data/lib/graphql/backtrace/trace.rb +12 -15
- data/lib/graphql/coercion_error.rb +1 -9
- data/lib/graphql/dataloader/async_dataloader.rb +85 -0
- data/lib/graphql/dataloader/source.rb +11 -3
- data/lib/graphql/dataloader.rb +109 -142
- data/lib/graphql/duration_encoding_error.rb +16 -0
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +170 -0
- data/lib/graphql/execution/interpreter/runtime.rb +70 -248
- data/lib/graphql/execution/interpreter.rb +91 -157
- data/lib/graphql/execution/lookahead.rb +88 -21
- data/lib/graphql/introspection/dynamic_fields.rb +1 -1
- data/lib/graphql/introspection/entry_points.rb +11 -5
- data/lib/graphql/introspection/schema_type.rb +3 -1
- data/lib/graphql/language/block_string.rb +34 -18
- data/lib/graphql/language/definition_slice.rb +1 -1
- data/lib/graphql/language/document_from_schema_definition.rb +37 -37
- data/lib/graphql/language/lexer.rb +271 -177
- data/lib/graphql/language/nodes.rb +74 -56
- data/lib/graphql/language/parser.rb +697 -1986
- data/lib/graphql/language/printer.rb +299 -146
- data/lib/graphql/language/sanitized_printer.rb +20 -22
- data/lib/graphql/language/static_visitor.rb +167 -0
- data/lib/graphql/language/visitor.rb +20 -81
- data/lib/graphql/language.rb +1 -0
- data/lib/graphql/load_application_object_failed_error.rb +5 -1
- data/lib/graphql/pagination/array_connection.rb +3 -3
- data/lib/graphql/pagination/connection.rb +28 -1
- data/lib/graphql/pagination/mongoid_relation_connection.rb +1 -2
- data/lib/graphql/pagination/relation_connection.rb +3 -3
- data/lib/graphql/query/context/scoped_context.rb +101 -0
- data/lib/graphql/query/context.rb +36 -98
- data/lib/graphql/query/null_context.rb +4 -11
- data/lib/graphql/query/validation_pipeline.rb +2 -2
- data/lib/graphql/query/variables.rb +3 -3
- data/lib/graphql/query.rb +13 -22
- data/lib/graphql/railtie.rb +9 -6
- data/lib/graphql/rake_task.rb +3 -12
- data/lib/graphql/schema/argument.rb +6 -1
- data/lib/graphql/schema/build_from_definition.rb +0 -11
- data/lib/graphql/schema/directive/one_of.rb +12 -0
- data/lib/graphql/schema/directive/specified_by.rb +14 -0
- data/lib/graphql/schema/directive.rb +1 -1
- data/lib/graphql/schema/enum.rb +3 -3
- data/lib/graphql/schema/field/connection_extension.rb +1 -15
- data/lib/graphql/schema/field/scope_extension.rb +8 -1
- data/lib/graphql/schema/field.rb +8 -5
- data/lib/graphql/schema/has_single_input_argument.rb +156 -0
- data/lib/graphql/schema/input_object.rb +2 -2
- data/lib/graphql/schema/interface.rb +10 -10
- data/lib/graphql/schema/introspection_system.rb +2 -0
- data/lib/graphql/schema/loader.rb +0 -2
- data/lib/graphql/schema/member/base_dsl_methods.rb +2 -1
- data/lib/graphql/schema/member/has_arguments.rb +61 -38
- data/lib/graphql/schema/member/has_fields.rb +8 -5
- data/lib/graphql/schema/member/has_interfaces.rb +23 -9
- data/lib/graphql/schema/member/scoped.rb +19 -0
- data/lib/graphql/schema/member/validates_input.rb +3 -3
- data/lib/graphql/schema/object.rb +8 -0
- data/lib/graphql/schema/printer.rb +8 -7
- data/lib/graphql/schema/relay_classic_mutation.rb +6 -128
- data/lib/graphql/schema/resolver.rb +7 -3
- data/lib/graphql/schema/scalar.rb +3 -3
- data/lib/graphql/schema/subscription.rb +11 -4
- data/lib/graphql/schema/union.rb +1 -1
- data/lib/graphql/schema/warden.rb +96 -94
- data/lib/graphql/schema.rb +219 -72
- data/lib/graphql/static_validation/all_rules.rb +1 -1
- data/lib/graphql/static_validation/base_visitor.rb +1 -1
- data/lib/graphql/static_validation/literal_validator.rb +1 -1
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +1 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +1 -1
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +1 -1
- data/lib/graphql/static_validation/validation_context.rb +5 -5
- data/lib/graphql/static_validation/validator.rb +3 -0
- data/lib/graphql/static_validation.rb +0 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +3 -2
- data/lib/graphql/subscriptions/event.rb +8 -2
- data/lib/graphql/subscriptions.rb +14 -12
- data/lib/graphql/testing/helpers.rb +125 -0
- data/lib/graphql/testing.rb +2 -0
- data/lib/graphql/tracing/appoptics_trace.rb +2 -2
- data/lib/graphql/tracing/appoptics_tracing.rb +2 -2
- data/lib/graphql/tracing/data_dog_trace.rb +21 -34
- data/lib/graphql/tracing/data_dog_tracing.rb +7 -21
- data/lib/graphql/tracing/legacy_hooks_trace.rb +74 -0
- data/lib/graphql/tracing/platform_tracing.rb +2 -0
- data/lib/graphql/tracing/{prometheus_tracing → prometheus_trace}/graphql_collector.rb +3 -1
- data/lib/graphql/tracing/sentry_trace.rb +94 -0
- data/lib/graphql/tracing/trace.rb +1 -0
- data/lib/graphql/tracing.rb +3 -1
- data/lib/graphql/types/iso_8601_duration.rb +77 -0
- data/lib/graphql/types/relay/connection_behaviors.rb +32 -2
- data/lib/graphql/types/relay/edge_behaviors.rb +7 -0
- data/lib/graphql/types.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +3 -3
- data/readme.md +12 -2
- metadata +33 -25
- data/lib/graphql/deprecation.rb +0 -9
- data/lib/graphql/filter.rb +0 -59
- data/lib/graphql/language/parser.y +0 -560
- data/lib/graphql/static_validation/type_stack.rb +0 -216
- data/lib/graphql/subscriptions/instrumentation.rb +0 -28
@@ -0,0 +1,170 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Execution
|
5
|
+
class Interpreter
|
6
|
+
class Runtime
|
7
|
+
module GraphQLResult
|
8
|
+
def initialize(result_name, parent_result, is_non_null_in_parent)
|
9
|
+
@graphql_parent = parent_result
|
10
|
+
if parent_result && parent_result.graphql_dead
|
11
|
+
@graphql_dead = true
|
12
|
+
end
|
13
|
+
@graphql_result_name = result_name
|
14
|
+
@graphql_is_non_null_in_parent = is_non_null_in_parent
|
15
|
+
# Jump through some hoops to avoid creating this duplicate storage if at all possible.
|
16
|
+
@graphql_metadata = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def path
|
20
|
+
@path ||= build_path([])
|
21
|
+
end
|
22
|
+
|
23
|
+
def build_path(path_array)
|
24
|
+
graphql_result_name && path_array.unshift(graphql_result_name)
|
25
|
+
@graphql_parent ? @graphql_parent.build_path(path_array) : path_array
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_accessor :graphql_dead
|
29
|
+
attr_reader :graphql_parent, :graphql_result_name, :graphql_is_non_null_in_parent
|
30
|
+
|
31
|
+
# @return [Hash] Plain-Ruby result data (`@graphql_metadata` contains Result wrapper objects)
|
32
|
+
attr_accessor :graphql_result_data
|
33
|
+
end
|
34
|
+
|
35
|
+
class GraphQLResultHash
|
36
|
+
def initialize(_result_name, _parent_result, _is_non_null_in_parent)
|
37
|
+
super
|
38
|
+
@graphql_result_data = {}
|
39
|
+
end
|
40
|
+
|
41
|
+
include GraphQLResult
|
42
|
+
|
43
|
+
attr_accessor :graphql_merged_into
|
44
|
+
|
45
|
+
def set_leaf(key, value)
|
46
|
+
# This is a hack.
|
47
|
+
# Basically, this object is merged into the root-level result at some point.
|
48
|
+
# But the problem is, some lazies are created whose closures retain reference to _this_
|
49
|
+
# object. When those lazies are resolved, they cause an update to this object.
|
50
|
+
#
|
51
|
+
# In order to return a proper top-level result, we have to update that top-level result object.
|
52
|
+
# In order to return a proper partial result (eg, for a directive), we have to update this object, too.
|
53
|
+
# Yowza.
|
54
|
+
if (t = @graphql_merged_into)
|
55
|
+
t.set_leaf(key, value)
|
56
|
+
end
|
57
|
+
|
58
|
+
@graphql_result_data[key] = value
|
59
|
+
# keep this up-to-date if it's been initialized
|
60
|
+
@graphql_metadata && @graphql_metadata[key] = value
|
61
|
+
|
62
|
+
value
|
63
|
+
end
|
64
|
+
|
65
|
+
def set_child_result(key, value)
|
66
|
+
if (t = @graphql_merged_into)
|
67
|
+
t.set_child_result(key, value)
|
68
|
+
end
|
69
|
+
@graphql_result_data[key] = value.graphql_result_data
|
70
|
+
# If we encounter some part of this response that requires metadata tracking,
|
71
|
+
# then create the metadata hash if necessary. It will be kept up-to-date after this.
|
72
|
+
(@graphql_metadata ||= @graphql_result_data.dup)[key] = value
|
73
|
+
value
|
74
|
+
end
|
75
|
+
|
76
|
+
def delete(key)
|
77
|
+
@graphql_metadata && @graphql_metadata.delete(key)
|
78
|
+
@graphql_result_data.delete(key)
|
79
|
+
end
|
80
|
+
|
81
|
+
def each
|
82
|
+
(@graphql_metadata || @graphql_result_data).each { |k, v| yield(k, v) }
|
83
|
+
end
|
84
|
+
|
85
|
+
def values
|
86
|
+
(@graphql_metadata || @graphql_result_data).values
|
87
|
+
end
|
88
|
+
|
89
|
+
def key?(k)
|
90
|
+
@graphql_result_data.key?(k)
|
91
|
+
end
|
92
|
+
|
93
|
+
def [](k)
|
94
|
+
(@graphql_metadata || @graphql_result_data)[k]
|
95
|
+
end
|
96
|
+
|
97
|
+
def merge_into(into_result)
|
98
|
+
self.each do |key, value|
|
99
|
+
case value
|
100
|
+
when GraphQLResultHash
|
101
|
+
next_into = into_result[key]
|
102
|
+
if next_into
|
103
|
+
value.merge_into(next_into)
|
104
|
+
else
|
105
|
+
into_result.set_child_result(key, value)
|
106
|
+
end
|
107
|
+
when GraphQLResultArray
|
108
|
+
# There's no special handling of arrays because currently, there's no way to split the execution
|
109
|
+
# of a list over several concurrent flows.
|
110
|
+
into_result.set_child_result(key, value)
|
111
|
+
else
|
112
|
+
# We have to assume that, since this passed the `fields_will_merge` selection,
|
113
|
+
# that the old and new values are the same.
|
114
|
+
into_result.set_leaf(key, value)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
@graphql_merged_into = into_result
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
class GraphQLResultArray
|
122
|
+
include GraphQLResult
|
123
|
+
|
124
|
+
def initialize(_result_name, _parent_result, _is_non_null_in_parent)
|
125
|
+
super
|
126
|
+
@graphql_result_data = []
|
127
|
+
end
|
128
|
+
|
129
|
+
def graphql_skip_at(index)
|
130
|
+
# Mark this index as dead. It's tricky because some indices may already be storing
|
131
|
+
# `Lazy`s. So the runtime is still holding indexes _before_ skipping,
|
132
|
+
# this object has to coordinate incoming writes to account for any already-skipped indices.
|
133
|
+
@skip_indices ||= []
|
134
|
+
@skip_indices << index
|
135
|
+
offset_by = @skip_indices.count { |skipped_idx| skipped_idx < index}
|
136
|
+
delete_at_index = index - offset_by
|
137
|
+
@graphql_metadata && @graphql_metadata.delete_at(delete_at_index)
|
138
|
+
@graphql_result_data.delete_at(delete_at_index)
|
139
|
+
end
|
140
|
+
|
141
|
+
def set_leaf(idx, value)
|
142
|
+
if @skip_indices
|
143
|
+
offset_by = @skip_indices.count { |skipped_idx| skipped_idx < idx }
|
144
|
+
idx -= offset_by
|
145
|
+
end
|
146
|
+
@graphql_result_data[idx] = value
|
147
|
+
@graphql_metadata && @graphql_metadata[idx] = value
|
148
|
+
value
|
149
|
+
end
|
150
|
+
|
151
|
+
def set_child_result(idx, value)
|
152
|
+
if @skip_indices
|
153
|
+
offset_by = @skip_indices.count { |skipped_idx| skipped_idx < idx }
|
154
|
+
idx -= offset_by
|
155
|
+
end
|
156
|
+
@graphql_result_data[idx] = value.graphql_result_data
|
157
|
+
# If we encounter some part of this response that requires metadata tracking,
|
158
|
+
# then create the metadata hash if necessary. It will be kept up-to-date after this.
|
159
|
+
(@graphql_metadata ||= @graphql_result_data.dup)[idx] = value
|
160
|
+
value
|
161
|
+
end
|
162
|
+
|
163
|
+
def values
|
164
|
+
(@graphql_metadata || @graphql_result_data)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|