Class: GraphQL::Functions::Array
- Defined in:
- lib/graphql/functions/array.rb
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#call(_, args, _) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/graphql/functions/array.rb', line 10 def call(_, args, _) query = args[:ids] ? @model_class.where(id: args[:ids]) : @model_class.all query = query.offset(args[:offset]) if args[:offset] query = query.limit(args[:limit]) if args[:limit] query end |
#query(*args) ⇒ Object
17 18 19 20 21 |
# File 'lib/graphql/functions/array.rb', line 17 def query(*args) relation = call(*args) filtered_relation = yield(relation) if block_given? filtered_relation || relation end |
#type ⇒ Object
23 24 25 |
# File 'lib/graphql/functions/array.rb', line 23 def type @type ||= self.class.types[!type_class] end |
#type_class ⇒ Object
27 28 29 |
# File 'lib/graphql/functions/array.rb', line 27 def type_class "Types::#{@model_class}Type".constantize end |