Class: GraphQL::Query::ParallelExecution::OperationResolution
- Inherits:
-
SerialExecution::OperationResolution
- Object
- SerialExecution::OperationResolution
- GraphQL::Query::ParallelExecution::OperationResolution
- Defined in:
- lib/graphql/query/parallel_execution.rb
Instance Attribute Summary
Attributes inherited from SerialExecution::OperationResolution
#ast_operation_definition, #execution_strategy, #query, #target
Instance Method Summary collapse
-
#finish_all_futures(result_object) ⇒ Object
Recurse over ‘result_object`, finding any futures and getting their finished values.
- #result ⇒ Object
Methods inherited from SerialExecution::OperationResolution
Constructor Details
This class inherits a constructor from GraphQL::Query::SerialExecution::OperationResolution
Instance Method Details
#finish_all_futures(result_object) ⇒ Object
Recurse over ‘result_object`, finding any futures and getting their finished values.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/graphql/query/parallel_execution.rb', line 42 def finish_all_futures(result_object) if result_object.is_a?(FutureFieldResolution) resolved_value = finish_all_futures(result_object.result) elsif result_object.is_a?(Hash) result_object.each do |key, value| result_object[key] = finish_all_futures(value) end resolved_value = result_object elsif result_object.is_a?(Array) resolved_value = result_object.map { |v| finish_all_futures(v) } else resolved_value = result_object end end |
#result ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/graphql/query/parallel_execution.rb', line 27 def result result_futures = super if execution_strategy.has_futures? finished_result = finish_all_futures(result_futures) else # Don't bother re-traversing the result if there are no futures. finished_result = result_futures end ensure execution_strategy.pool.terminate finished_result end |