Sha256: 7fbccb116604b828f41bc17de978ad188d5c8de8c8c739acd74702d2cfd48abd
Contents?: true
Size: 855 Bytes
Versions: 4
Compression:
Stored size: 855 Bytes
Contents
# frozen_string_literal: true module Resolvers class CategorySearch < Resolvers::BaseSearchResolver type Types::CategoryType.connection_type description 'Lists categories' class OrderEnum < Types::BaseEnum graphql_name 'CategoryOrder' value 'RECENT' value 'NAME' end scope { Category.all } option :id, type: types.String, with: :apply_id_filter option :name, type: types.String, with: :apply_name_filter option :order, type: OrderEnum, default: 'RECENT' def apply_id_filter(scope, value) scope.where id: value end def apply_name_filter(scope, value) scope.where 'name LIKE ?', escape_search_term(value) end def apply_order_with_recent(scope) scope.order 'id DESC' end def apply_order_with_name(scope) scope.order 'name ASC' end end end
Version data entries
4 entries across 4 versions & 1 rubygems