Class: GraphQL::Query::SelectionResolver
- Inherits:
-
Object
- Object
- GraphQL::Query::SelectionResolver
- Defined in:
- lib/graph_ql/query/selection_resolver.rb
Constant Summary collapse
- RESOLUTION_STRATEGIES =
{ GraphQL::Nodes::Field => GraphQL::Query::FieldResolutionStrategy, GraphQL::Nodes::FragmentSpread => GraphQL::Query::FragmentSpreadResolutionStrategy, GraphQL::Nodes::InlineFragment => GraphQL::Query::InlineFragmentResolutionStrategy, }
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(target, type, selections, operation_resolver) ⇒ SelectionResolver
constructor
A new instance of SelectionResolver.
Constructor Details
#initialize(target, type, selections, operation_resolver) ⇒ SelectionResolver
Returns a new instance of SelectionResolver.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/graph_ql/query/selection_resolver.rb', line 10 def initialize(target, type, selections, operation_resolver) @result = selections.reduce({}) do |memo, ast_field| chain = GraphQL::DirectiveChain.new(ast_field, operation_resolver) { strategy_class = RESOLUTION_STRATEGIES[ast_field.class] strategy = strategy_class.new(ast_field, type, target, operation_resolver) strategy.result } memo.merge(chain.result) end end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
2 3 4 |
# File 'lib/graph_ql/query/selection_resolver.rb', line 2 def result @result end |