graphql 2.0.13 → 2.3.10
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/mutation_root_generator.rb +2 -2
- 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/mutation_delete_generator.rb +1 -1
- data/lib/generators/graphql/mutation_update_generator.rb +1 -1
- data/lib/generators/graphql/relay.rb +18 -1
- 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 +8 -0
- data/lib/graphql/analysis/analyzer.rb +89 -0
- data/lib/graphql/analysis/field_usage.rb +82 -0
- data/lib/graphql/analysis/max_query_complexity.rb +20 -0
- data/lib/graphql/analysis/max_query_depth.rb +20 -0
- data/lib/graphql/analysis/query_complexity.rb +183 -0
- data/lib/graphql/analysis/query_depth.rb +58 -0
- data/lib/graphql/analysis/visitor.rb +283 -0
- data/lib/graphql/analysis.rb +92 -1
- data/lib/graphql/backtrace/inspect_result.rb +0 -12
- data/lib/graphql/backtrace/table.rb +2 -2
- data/lib/graphql/backtrace/trace.rb +93 -0
- data/lib/graphql/backtrace/tracer.rb +1 -1
- data/lib/graphql/backtrace.rb +2 -1
- data/lib/graphql/coercion_error.rb +1 -9
- data/lib/graphql/dataloader/async_dataloader.rb +88 -0
- data/lib/graphql/dataloader/null_dataloader.rb +1 -1
- data/lib/graphql/dataloader/request.rb +5 -0
- data/lib/graphql/dataloader/source.rb +89 -45
- data/lib/graphql/dataloader.rb +115 -142
- data/lib/graphql/duration_encoding_error.rb +16 -0
- data/lib/graphql/execution/interpreter/argument_value.rb +5 -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/resolve.rb +19 -0
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +175 -0
- data/lib/graphql/execution/interpreter/runtime.rb +331 -455
- data/lib/graphql/execution/interpreter.rb +125 -61
- data/lib/graphql/execution/lazy.rb +6 -12
- data/lib/graphql/execution/lookahead.rb +124 -46
- data/lib/graphql/execution/multiplex.rb +3 -117
- data/lib/graphql/execution.rb +0 -1
- data/lib/graphql/introspection/directive_type.rb +3 -3
- data/lib/graphql/introspection/dynamic_fields.rb +1 -1
- data/lib/graphql/introspection/entry_points.rb +11 -5
- data/lib/graphql/introspection/field_type.rb +2 -2
- data/lib/graphql/introspection/schema_type.rb +10 -13
- data/lib/graphql/introspection/type_type.rb +17 -10
- data/lib/graphql/introspection.rb +3 -2
- 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 +75 -59
- data/lib/graphql/language/lexer.rb +358 -1506
- data/lib/graphql/language/nodes.rb +166 -93
- data/lib/graphql/language/parser.rb +795 -1953
- data/lib/graphql/language/printer.rb +340 -160
- data/lib/graphql/language/sanitized_printer.rb +21 -23
- data/lib/graphql/language/static_visitor.rb +167 -0
- data/lib/graphql/language/visitor.rb +188 -141
- data/lib/graphql/language.rb +61 -1
- data/lib/graphql/load_application_object_failed_error.rb +5 -1
- data/lib/graphql/pagination/active_record_relation_connection.rb +0 -8
- data/lib/graphql/pagination/array_connection.rb +6 -6
- data/lib/graphql/pagination/connection.rb +33 -6
- data/lib/graphql/pagination/mongoid_relation_connection.rb +1 -2
- data/lib/graphql/query/context/scoped_context.rb +101 -0
- data/lib/graphql/query/context.rb +117 -112
- data/lib/graphql/query/null_context.rb +12 -25
- data/lib/graphql/query/validation_pipeline.rb +6 -5
- data/lib/graphql/query/variables.rb +3 -3
- data/lib/graphql/query.rb +86 -30
- data/lib/graphql/railtie.rb +9 -6
- data/lib/graphql/rake_task.rb +29 -11
- data/lib/graphql/rubocop/graphql/base_cop.rb +1 -1
- data/lib/graphql/schema/addition.rb +59 -23
- data/lib/graphql/schema/always_visible.rb +11 -0
- data/lib/graphql/schema/argument.rb +55 -26
- data/lib/graphql/schema/base_64_encoder.rb +3 -5
- data/lib/graphql/schema/build_from_definition.rb +56 -32
- data/lib/graphql/schema/directive/one_of.rb +24 -0
- data/lib/graphql/schema/directive/specified_by.rb +14 -0
- data/lib/graphql/schema/directive/transform.rb +1 -1
- data/lib/graphql/schema/directive.rb +15 -3
- data/lib/graphql/schema/enum.rb +35 -24
- data/lib/graphql/schema/enum_value.rb +2 -3
- data/lib/graphql/schema/field/connection_extension.rb +2 -16
- data/lib/graphql/schema/field/scope_extension.rb +8 -1
- data/lib/graphql/schema/field.rb +147 -107
- data/lib/graphql/schema/field_extension.rb +1 -4
- data/lib/graphql/schema/find_inherited_value.rb +2 -7
- data/lib/graphql/schema/has_single_input_argument.rb +158 -0
- data/lib/graphql/schema/input_object.rb +47 -11
- data/lib/graphql/schema/interface.rb +15 -21
- data/lib/graphql/schema/introspection_system.rb +7 -17
- data/lib/graphql/schema/late_bound_type.rb +10 -0
- data/lib/graphql/schema/list.rb +2 -2
- data/lib/graphql/schema/loader.rb +2 -3
- data/lib/graphql/schema/member/base_dsl_methods.rb +18 -14
- data/lib/graphql/schema/member/build_type.rb +11 -3
- data/lib/graphql/schema/member/has_arguments.rb +170 -130
- 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 +81 -61
- data/lib/graphql/schema/member/has_fields.rb +100 -38
- data/lib/graphql/schema/member/has_interfaces.rb +65 -10
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +5 -1
- data/lib/graphql/schema/member/has_validators.rb +32 -6
- data/lib/graphql/schema/member/relay_shortcuts.rb +19 -0
- data/lib/graphql/schema/member/scoped.rb +19 -0
- data/lib/graphql/schema/member/type_system_helpers.rb +16 -0
- data/lib/graphql/schema/member/validates_input.rb +3 -3
- data/lib/graphql/schema/mutation.rb +7 -0
- data/lib/graphql/schema/object.rb +16 -5
- data/lib/graphql/schema/printer.rb +11 -8
- data/lib/graphql/schema/relay_classic_mutation.rb +7 -129
- data/lib/graphql/schema/resolver/has_payload_type.rb +9 -9
- data/lib/graphql/schema/resolver.rb +47 -32
- data/lib/graphql/schema/scalar.rb +3 -3
- data/lib/graphql/schema/subscription.rb +11 -4
- data/lib/graphql/schema/subset.rb +397 -0
- data/lib/graphql/schema/timeout.rb +25 -29
- data/lib/graphql/schema/type_expression.rb +2 -2
- data/lib/graphql/schema/type_membership.rb +3 -0
- data/lib/graphql/schema/union.rb +11 -2
- data/lib/graphql/schema/unique_within_type.rb +1 -1
- data/lib/graphql/schema/validator/all_validator.rb +60 -0
- data/lib/graphql/schema/validator.rb +4 -2
- data/lib/graphql/schema/warden.rb +238 -93
- data/lib/graphql/schema.rb +498 -103
- data/lib/graphql/static_validation/all_rules.rb +2 -1
- data/lib/graphql/static_validation/base_visitor.rb +7 -6
- data/lib/graphql/static_validation/definition_dependencies.rb +7 -1
- data/lib/graphql/static_validation/literal_validator.rb +24 -7
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +1 -1
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +1 -1
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +1 -2
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +1 -1
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +12 -4
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +10 -10
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +1 -1
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +1 -1
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +1 -1
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +66 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +29 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +1 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -4
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +5 -5
- data/lib/graphql/static_validation/rules/subscription_root_exists.rb +1 -1
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +18 -27
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +1 -1
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
- data/lib/graphql/static_validation/validation_context.rb +5 -5
- data/lib/graphql/static_validation/validator.rb +4 -1
- data/lib/graphql/static_validation.rb +0 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +11 -4
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +11 -5
- data/lib/graphql/subscriptions/event.rb +11 -10
- data/lib/graphql/subscriptions/serialize.rb +2 -0
- data/lib/graphql/subscriptions.rb +20 -13
- data/lib/graphql/testing/helpers.rb +151 -0
- data/lib/graphql/testing.rb +2 -0
- data/lib/graphql/tracing/active_support_notifications_trace.rb +16 -0
- data/lib/graphql/tracing/appoptics_trace.rb +251 -0
- data/lib/graphql/tracing/appoptics_tracing.rb +2 -2
- data/lib/graphql/tracing/appsignal_trace.rb +77 -0
- data/lib/graphql/tracing/data_dog_trace.rb +183 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +9 -21
- data/lib/graphql/{execution/instrumentation.rb → tracing/legacy_hooks_trace.rb} +10 -28
- data/lib/graphql/tracing/legacy_trace.rb +69 -0
- data/lib/graphql/tracing/new_relic_trace.rb +75 -0
- data/lib/graphql/tracing/notifications_trace.rb +45 -0
- data/lib/graphql/tracing/platform_trace.rb +118 -0
- data/lib/graphql/tracing/platform_tracing.rb +17 -3
- data/lib/graphql/tracing/{prometheus_tracing → prometheus_trace}/graphql_collector.rb +4 -2
- data/lib/graphql/tracing/prometheus_trace.rb +89 -0
- data/lib/graphql/tracing/prometheus_tracing.rb +3 -3
- data/lib/graphql/tracing/scout_trace.rb +72 -0
- data/lib/graphql/tracing/sentry_trace.rb +112 -0
- data/lib/graphql/tracing/statsd_trace.rb +56 -0
- data/lib/graphql/tracing/trace.rb +76 -0
- data/lib/graphql/tracing.rb +20 -40
- data/lib/graphql/type_kinds.rb +7 -4
- data/lib/graphql/types/iso_8601_duration.rb +77 -0
- data/lib/graphql/types/relay/base_connection.rb +1 -1
- data/lib/graphql/types/relay/connection_behaviors.rb +68 -6
- data/lib/graphql/types/relay/edge_behaviors.rb +33 -5
- data/lib/graphql/types/relay/node_behaviors.rb +8 -2
- data/lib/graphql/types/relay/page_info_behaviors.rb +11 -2
- data/lib/graphql/types/relay.rb +0 -1
- data/lib/graphql/types/string.rb +1 -1
- data/lib/graphql/types.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +27 -20
- data/readme.md +13 -3
- metadata +96 -47
- data/lib/graphql/analysis/ast/analyzer.rb +0 -84
- data/lib/graphql/analysis/ast/field_usage.rb +0 -57
- data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -22
- data/lib/graphql/analysis/ast/max_query_depth.rb +0 -22
- data/lib/graphql/analysis/ast/query_complexity.rb +0 -230
- data/lib/graphql/analysis/ast/query_depth.rb +0 -55
- data/lib/graphql/analysis/ast/visitor.rb +0 -269
- data/lib/graphql/analysis/ast.rb +0 -81
- data/lib/graphql/deprecation.rb +0 -9
- data/lib/graphql/filter.rb +0 -53
- data/lib/graphql/language/lexer.rl +0 -280
- data/lib/graphql/language/parser.y +0 -554
- data/lib/graphql/language/token.rb +0 -34
- data/lib/graphql/schema/base_64_bp.rb +0 -26
- data/lib/graphql/schema/invalid_type_error.rb +0 -7
- data/lib/graphql/static_validation/type_stack.rb +0 -216
- data/lib/graphql/subscriptions/instrumentation.rb +0 -28
- data/lib/graphql/types/relay/default_relay.rb +0 -21
@@ -1,216 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module StaticValidation
|
4
|
-
# - Ride along with `GraphQL::Language::Visitor`
|
5
|
-
# - Track type info, expose it to validators
|
6
|
-
class TypeStack
|
7
|
-
# These are jumping-off points for infering types down the tree
|
8
|
-
TYPE_INFERRENCE_ROOTS = [
|
9
|
-
GraphQL::Language::Nodes::OperationDefinition,
|
10
|
-
GraphQL::Language::Nodes::FragmentDefinition,
|
11
|
-
]
|
12
|
-
|
13
|
-
# @return [GraphQL::Schema] the schema whose types are present in this document
|
14
|
-
attr_reader :schema
|
15
|
-
|
16
|
-
# When it enters an object (starting with query or mutation root), it's pushed on this stack.
|
17
|
-
# When it exits, it's popped off.
|
18
|
-
# @return [Array<GraphQL::ObjectType, GraphQL::Union, GraphQL::Interface>]
|
19
|
-
attr_reader :object_types
|
20
|
-
|
21
|
-
# When it enters a field, it's pushed on this stack (useful for nested fields, args).
|
22
|
-
# When it exits, it's popped off.
|
23
|
-
# @return [Array<GraphQL::Field>] fields which have been entered
|
24
|
-
attr_reader :field_definitions
|
25
|
-
|
26
|
-
# Directives are pushed on, then popped off while traversing the tree
|
27
|
-
# @return [Array<GraphQL::Node::Directive>] directives which have been entered
|
28
|
-
attr_reader :directive_definitions
|
29
|
-
|
30
|
-
# @return [Array<GraphQL::Node::Argument>] arguments which have been entered
|
31
|
-
attr_reader :argument_definitions
|
32
|
-
|
33
|
-
# @return [Array<String>] fields which have been entered (by their AST name)
|
34
|
-
attr_reader :path
|
35
|
-
|
36
|
-
# @param schema [GraphQL::Schema] the schema whose types to use when climbing this document
|
37
|
-
# @param visitor [GraphQL::Language::Visitor] a visitor to follow & watch the types
|
38
|
-
def initialize(schema, visitor)
|
39
|
-
@schema = schema
|
40
|
-
@object_types = []
|
41
|
-
@field_definitions = []
|
42
|
-
@directive_definitions = []
|
43
|
-
@argument_definitions = []
|
44
|
-
@path = []
|
45
|
-
|
46
|
-
PUSH_STRATEGIES.each do |node_class, strategy|
|
47
|
-
visitor[node_class].enter << EnterWithStrategy.new(self, strategy)
|
48
|
-
visitor[node_class].leave << LeaveWithStrategy.new(self, strategy)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
|
55
|
-
module FragmentWithTypeStrategy
|
56
|
-
def push(stack, node)
|
57
|
-
object_type = if node.type
|
58
|
-
stack.schema.get_type(node.type.name)
|
59
|
-
else
|
60
|
-
stack.object_types.last
|
61
|
-
end
|
62
|
-
if !object_type.nil?
|
63
|
-
object_type = object_type.unwrap
|
64
|
-
end
|
65
|
-
stack.object_types.push(object_type)
|
66
|
-
push_path_member(stack, node)
|
67
|
-
end
|
68
|
-
|
69
|
-
def pop(stack, node)
|
70
|
-
stack.object_types.pop
|
71
|
-
stack.path.pop
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
module FragmentDefinitionStrategy
|
76
|
-
extend FragmentWithTypeStrategy
|
77
|
-
module_function
|
78
|
-
def push_path_member(stack, node)
|
79
|
-
stack.path.push("fragment #{node.name}")
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
module InlineFragmentStrategy
|
84
|
-
extend FragmentWithTypeStrategy
|
85
|
-
module_function
|
86
|
-
def push_path_member(stack, node)
|
87
|
-
stack.path.push("...#{node.type ? " on #{node.type.to_query_string}" : ""}")
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
module OperationDefinitionStrategy
|
92
|
-
module_function
|
93
|
-
def push(stack, node)
|
94
|
-
# eg, QueryType, MutationType
|
95
|
-
object_type = stack.schema.root_type_for_operation(node.operation_type)
|
96
|
-
stack.object_types.push(object_type)
|
97
|
-
stack.path.push("#{node.operation_type}#{node.name ? " #{node.name}" : ""}")
|
98
|
-
end
|
99
|
-
|
100
|
-
def pop(stack, node)
|
101
|
-
stack.object_types.pop
|
102
|
-
stack.path.pop
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
module FieldStrategy
|
107
|
-
module_function
|
108
|
-
def push(stack, node)
|
109
|
-
parent_type = stack.object_types.last
|
110
|
-
parent_type = parent_type.unwrap
|
111
|
-
|
112
|
-
field_definition = stack.schema.get_field(parent_type, node.name)
|
113
|
-
stack.field_definitions.push(field_definition)
|
114
|
-
if !field_definition.nil?
|
115
|
-
next_object_type = field_definition.type
|
116
|
-
stack.object_types.push(next_object_type)
|
117
|
-
else
|
118
|
-
stack.object_types.push(nil)
|
119
|
-
end
|
120
|
-
stack.path.push(node.alias || node.name)
|
121
|
-
end
|
122
|
-
|
123
|
-
def pop(stack, node)
|
124
|
-
stack.field_definitions.pop
|
125
|
-
stack.object_types.pop
|
126
|
-
stack.path.pop
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
module DirectiveStrategy
|
131
|
-
module_function
|
132
|
-
def push(stack, node)
|
133
|
-
directive_defn = stack.schema.directives[node.name]
|
134
|
-
stack.directive_definitions.push(directive_defn)
|
135
|
-
end
|
136
|
-
|
137
|
-
def pop(stack, node)
|
138
|
-
stack.directive_definitions.pop
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
module ArgumentStrategy
|
143
|
-
module_function
|
144
|
-
# Push `argument_defn` onto the stack.
|
145
|
-
# It's possible that `argument_defn` will be nil.
|
146
|
-
# Push it anyways so `pop` has something to pop.
|
147
|
-
def push(stack, node)
|
148
|
-
if stack.argument_definitions.last
|
149
|
-
arg_type = stack.argument_definitions.last.type.unwrap
|
150
|
-
if arg_type.kind.input_object?
|
151
|
-
argument_defn = arg_type.arguments[node.name]
|
152
|
-
else
|
153
|
-
argument_defn = nil
|
154
|
-
end
|
155
|
-
elsif stack.directive_definitions.last
|
156
|
-
argument_defn = stack.directive_definitions.last.arguments[node.name]
|
157
|
-
elsif stack.field_definitions.last
|
158
|
-
argument_defn = stack.field_definitions.last.arguments[node.name]
|
159
|
-
else
|
160
|
-
argument_defn = nil
|
161
|
-
end
|
162
|
-
stack.argument_definitions.push(argument_defn)
|
163
|
-
stack.path.push(node.name)
|
164
|
-
end
|
165
|
-
|
166
|
-
def pop(stack, node)
|
167
|
-
stack.argument_definitions.pop
|
168
|
-
stack.path.pop
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
module FragmentSpreadStrategy
|
173
|
-
module_function
|
174
|
-
def push(stack, node)
|
175
|
-
stack.path.push("... #{node.name}")
|
176
|
-
end
|
177
|
-
|
178
|
-
def pop(stack, node)
|
179
|
-
stack.path.pop
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
PUSH_STRATEGIES = {
|
184
|
-
GraphQL::Language::Nodes::FragmentDefinition => FragmentDefinitionStrategy,
|
185
|
-
GraphQL::Language::Nodes::InlineFragment => InlineFragmentStrategy,
|
186
|
-
GraphQL::Language::Nodes::FragmentSpread => FragmentSpreadStrategy,
|
187
|
-
GraphQL::Language::Nodes::Argument => ArgumentStrategy,
|
188
|
-
GraphQL::Language::Nodes::Field => FieldStrategy,
|
189
|
-
GraphQL::Language::Nodes::Directive => DirectiveStrategy,
|
190
|
-
GraphQL::Language::Nodes::OperationDefinition => OperationDefinitionStrategy,
|
191
|
-
}
|
192
|
-
|
193
|
-
class EnterWithStrategy
|
194
|
-
def initialize(stack, strategy)
|
195
|
-
@stack = stack
|
196
|
-
@strategy = strategy
|
197
|
-
end
|
198
|
-
|
199
|
-
def call(node, parent)
|
200
|
-
@strategy.push(@stack, node)
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
class LeaveWithStrategy
|
205
|
-
def initialize(stack, strategy)
|
206
|
-
@stack = stack
|
207
|
-
@strategy = strategy
|
208
|
-
end
|
209
|
-
|
210
|
-
def call(node, parent)
|
211
|
-
@strategy.pop(@stack, node)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
class Subscriptions
|
4
|
-
# Wrap the root fields of the subscription type with special logic for:
|
5
|
-
# - Registering the subscription during the first execution
|
6
|
-
# - Evaluating the triggered portion(s) of the subscription during later execution
|
7
|
-
class Instrumentation
|
8
|
-
def initialize(schema:)
|
9
|
-
@schema = schema
|
10
|
-
end
|
11
|
-
|
12
|
-
# If needed, prepare to gather events which this query subscribes to
|
13
|
-
def before_query(query)
|
14
|
-
if query.subscription? && !query.subscription_update?
|
15
|
-
query.context.namespace(:subscriptions)[:events] = []
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# After checking the root fields, pass the gathered events to the store
|
20
|
-
def after_query(query)
|
21
|
-
events = query.context.namespace(:subscriptions)[:events]
|
22
|
-
if events && events.any?
|
23
|
-
@schema.subscriptions.write_subscription(query, events)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphQL
|
4
|
-
module Types
|
5
|
-
module Relay
|
6
|
-
module DefaultRelay
|
7
|
-
def self.extended(child_class)
|
8
|
-
child_class.default_relay(true)
|
9
|
-
end
|
10
|
-
|
11
|
-
def default_relay(new_value)
|
12
|
-
@default_relay = new_value
|
13
|
-
end
|
14
|
-
|
15
|
-
def default_relay?
|
16
|
-
!!@default_relay
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|