Class: Taro::Types::ObjectTypes::PageType
- Inherits:
-
ResponseType
- Object
- BaseType
- Taro::Types::ObjectType
- ResponseType
- Taro::Types::ObjectTypes::PageType
- Extended by:
- Shared::ItemType
- Defined in:
- lib/taro/types/object_types/page_type.rb
Overview
Abstract base class for Page types (paginated ActiveRecord data). Unlike other types, this one should not be manually inherited from, but is used indirectly via ‘page_of: SomeType`.
The gem rails_cursor_pagination must be installed to use this.
Instance Attribute Summary
Attributes included from Shared::ItemType
Class Method Summary collapse
- .default_openapi_name ⇒ Object
- .derive_from(from_type) ⇒ Object
- .render(relation, after:, limit: 20, order_by: nil, order: nil) ⇒ Object
Methods included from Shared::ItemType
Methods inherited from ResponseType
Methods included from Shared::Fields
Methods included from Shared::ObjectCoercion
#coerce_input, #coerce_response
Methods included from Shared::CustomFieldResolvers
Class Method Details
.default_openapi_name ⇒ Object
26 27 28 |
# File 'lib/taro/types/object_types/page_type.rb', line 26 def self.default_openapi_name "#{item_type.openapi_name}_Page" end |
.derive_from(from_type) ⇒ Object
10 11 12 13 14 |
# File 'lib/taro/types/object_types/page_type.rb', line 10 def self.derive_from(from_type) super field(:page, array_of: from_type.name, null: false) field(:page_info, type: 'Taro::Types::ObjectTypes::PageInfoType', null: false) end |
.render(relation, after:, limit: 20, order_by: nil, order: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/taro/types/object_types/page_type.rb', line 16 def self.render(relation, after:, limit: 20, order_by: nil, order: nil) result = RailsCursorPagination::Paginator.new( relation, limit:, order_by:, order:, after: ).fetch result[:page].map! { |el| el.fetch(:data) } super(result) end |