class GraphQL::Functions::Array

Public Instance Methods

call(*attrs) click to toggle source
# File lib/graphql/functions/array.rb, line 12
def call(*attrs)
  _, args, = attrs
  ids_filter = { id: args[:ids] } if args[:ids]
  order_by = args[:order_by].try(:to_sym)
  order = args[:desc] ? { order_by => :desc } : order_by
  relation = @model_class
    .all
    .where(ids_filter)
    .offset(args[:offset])
    .limit(args[:limit])
    .order(order)

  (query(relation, *attrs) if respond_to?(:query)) || relation
end
type() click to toggle source
# File lib/graphql/functions/array.rb, line 27
def type
  @type ||= self.class.types[!type_class]
end
type_class() click to toggle source
# File lib/graphql/functions/array.rb, line 31
def type_class
  "Types::#{@model_class}Type".constantize
end