field :items, [wrapped_type], null: false, method: :to_a
field :total_count, Integer, null: false
end
end
end
class PageBuilder
def initialize(scope, limit, offset)
@scope = scope
@limit = limit
@offset = offset
end
def items
@scope.limit(limit).offset(offset)
end
def total_count
@scope.count
end
end
class SomeType
field :seo_settings, Paginated[Types::SeoSettingType], null: false,
preauthorize: {to: :index?, with: SeoSettingPolicy} do
argument :limit, Integer, required: true
argument :offset, Integer, required: true
end
def seo_settings(limit:, offset:)
PageBuilder.new(SeoSetting.order(created_at: :desc), limit, offset)
end
end
Круто, попробую👍
Обсуждают сегодня