Class: GraphQL::Execution::Multiplex Private
- Inherits:
-
Object
- Object
- GraphQL::Execution::Multiplex
- Includes:
- Tracing::Traceable
- Defined in:
- lib/graphql/execution/multiplex.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Execute multiple queries under the same multiplex “umbrella”. They can share a batching context and reduce redundant database hits.
The flow is:
- Multiplex instrumentation setup
- Query instrumentation setup
- Analyze the multiplex + each query
- Begin each query
- Resolve lazy values, breadth-first across all queries
- Finish each query (eg, get errors)
- Query instrumentation teardown
- Multiplex instrumentation teardown
If one query raises an application error, all queries will be in undefined states.
Validation errors and GraphQL::ExecutionErrors are handled in isolation: one of these errors in one query will not affect the other queries.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
private
-
#dataloader ⇒ Object
readonly
private
-
#max_complexity ⇒ Object
readonly
private
-
#queries ⇒ Object
readonly
private
-
#schema ⇒ Object
readonly
private
Instance Method Summary collapse
-
#initialize(schema:, queries:, context:, max_complexity:) ⇒ Multiplex
constructor
private
A new instance of Multiplex.
Methods included from Tracing::Traceable
Constructor Details
#initialize(schema:, queries:, context:, max_complexity:) ⇒ Multiplex
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Multiplex.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/graphql/execution/multiplex.rb', line 30 def initialize(schema:, queries:, context:, max_complexity:) @schema = schema @queries = queries @queries.each { |q| q.multiplex = self } @context = context @dataloader = @context[:dataloader] ||= @schema.dataloader_class.new @tracers = schema.tracers + (context[:tracers] || []) # Support `context: {backtrace: true}` if context[:backtrace] && !@tracers.include?(GraphQL::Backtrace::Tracer) @tracers << GraphQL::Backtrace::Tracer end @max_complexity = max_complexity end |
Instance Attribute Details
#context ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/graphql/execution/multiplex.rb', line 28 def context @context end |
#dataloader ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/graphql/execution/multiplex.rb', line 28 def dataloader @dataloader end |
#max_complexity ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/graphql/execution/multiplex.rb', line 28 def max_complexity @max_complexity end |
#queries ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/graphql/execution/multiplex.rb', line 28 def queries @queries end |
#schema ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/graphql/execution/multiplex.rb', line 28 def schema @schema end |