class GraphQL::SmartSelect::Resolver

Resolve the minimum required fields for the query

Attributes

ctx[R]
relation[R]
smart_select[R]

Public Class Methods

new(relation, ctx, smart_select) click to toggle source
# File lib/graphql/smart_select/resolver.rb, line 15
def initialize(relation, ctx, smart_select)
  @smart_select = smart_select
  @relation = relation
  @ctx = ctx
end

Public Instance Methods

resolve() click to toggle source
# File lib/graphql/smart_select/resolver.rb, line 21
def resolve
  reject_virtual_fields(
    query_fields |
      Assosiations.new(relation, query_fields).expose |
      Options.new(list_of_nodes, smart_select).expose
  ).map(&:to_sym)
end

Private Instance Methods

list_of_nodes() click to toggle source
# File lib/graphql/smart_select/resolver.rb, line 31
def list_of_nodes
  @list_of_nodes ||= ConnectionsProxy.call(ctx) do
    ctx.irep_node.typed_children[ctx.type.unwrap]
  end
end
query_fields() click to toggle source
# File lib/graphql/smart_select/resolver.rb, line 37
def query_fields
  @query_fields ||= list_of_nodes.keys.map(&:underscore)
end
reject_virtual_fields(fields_for_select) click to toggle source
# File lib/graphql/smart_select/resolver.rb, line 41
def reject_virtual_fields(fields_for_select)
  relation.model.column_names & fields_for_select
end