Class: GraphQL::Stitching::Executor
- Inherits:
-
Object
- Object
- GraphQL::Stitching::Executor
- Defined in:
- lib/graphql/stitching/executor.rb,
lib/graphql/stitching/executor/shaper.rb,
lib/graphql/stitching/executor/root_source.rb,
lib/graphql/stitching/executor/resolver_source.rb
Defined Under Namespace
Classes: ResolverSource, RootSource, Shaper
Instance Attribute Summary collapse
-
#data ⇒ Hash
readonly
An aggregate data payload to return.
-
#errors ⇒ Array<Hash>
readonly
Aggregate GraphQL errors to return.
-
#query_count ⇒ Integer
Tally of queries performed while executing.
-
#request ⇒ Request
readonly
The stitching request to execute.
Instance Method Summary collapse
-
#initialize(request, nonblocking: false) ⇒ Executor
constructor
A new instance of Executor.
- #perform(raw: false) ⇒ Object
Constructor Details
#initialize(request, nonblocking: false) ⇒ Executor
Returns a new instance of Executor.
23 24 25 26 27 28 29 30 |
# File 'lib/graphql/stitching/executor.rb', line 23 def initialize(request, nonblocking: false) @request = request @data = {} @errors = [] @query_count = 0 @exec_cycles = 0 @dataloader = GraphQL::Dataloader.new(nonblocking: nonblocking) end |
Instance Attribute Details
#data ⇒ Hash (readonly)
Returns an aggregate data payload to return.
15 16 17 |
# File 'lib/graphql/stitching/executor.rb', line 15 def data @data end |
#errors ⇒ Array<Hash> (readonly)
Returns aggregate GraphQL errors to return.
18 19 20 |
# File 'lib/graphql/stitching/executor.rb', line 18 def errors @errors end |
#query_count ⇒ Integer
Returns tally of queries performed while executing.
21 22 23 |
# File 'lib/graphql/stitching/executor.rb', line 21 def query_count @query_count end |
#request ⇒ Request (readonly)
Returns the stitching request to execute.
12 13 14 |
# File 'lib/graphql/stitching/executor.rb', line 12 def request @request end |
Instance Method Details
#perform(raw: false) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/graphql/stitching/executor.rb', line 32 def perform(raw: false) exec! result = {} if @data && @data.length > 0 result["data"] = raw ? @data : Shaper.new(@request).perform!(@data) end if @errors.length > 0 result["errors"] = @errors end result end |