Class: GraphQL::Functions::Array
- Defined in:
- lib/graphql/functions/array.rb
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#call(*attrs) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# 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 ⇒ Object
27 28 29 |
# File 'lib/graphql/functions/array.rb', line 27 def type @type ||= self.class.types[!type_class] end |
#type_class ⇒ Object
31 32 33 |
# File 'lib/graphql/functions/array.rb', line 31 def type_class "Types::#{@model_class}Type".constantize end |