Class: GraphQL::Query::SelectionResolver

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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::Query::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

#resultObject (readonly)

Returns the value of attribute result.



2
3
4
# File 'lib/graph_ql/query/selection_resolver.rb', line 2

def result
  @result
end