Class: Gitlab::Graphql::Pagination::ActiveRecordArrayConnection
- Inherits:
-
GraphQL::Pagination::ArrayConnection
- Object
- GraphQL::Pagination::ArrayConnection
- Gitlab::Graphql::Pagination::ActiveRecordArrayConnection
- Includes:
- ConnectionCollectionMethods, ConnectionRedaction
- Defined in:
- lib/gitlab/graphql/pagination/active_record_array_connection.rb
Instance Method Summary collapse
- #cursor_for(item) ⇒ Object
-
#dup ⇒ Object
Part of the implied interface for default objects for BatchLoader: objects must be clonable.
- #next_page? ⇒ Boolean (also: #has_next_page)
- #nodes ⇒ Object
- #previous_page? ⇒ Boolean (also: #has_previous_page)
Instance Method Details
#cursor_for(item) ⇒ Object
52 53 54 55 56 |
# File 'lib/gitlab/graphql/pagination/active_record_array_connection.rb', line 52 def cursor_for(item) # item could be a batch loaded item. Sync it to have the id. cursor = { 'id' => Gitlab::Graphql::Lazy.force(item).id.to_s } encode(cursor.to_json) end |
#dup ⇒ Object
Part of the implied interface for default objects for BatchLoader: objects must be clonable
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/gitlab/graphql/pagination/active_record_array_connection.rb', line 59 def dup self.class.new( items.dup, context: context, first: first, after: after, max_page_size: max_page_size, last: last, before: before ) end |
#next_page? ⇒ Boolean Also known as: has_next_page
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gitlab/graphql/pagination/active_record_array_connection.rb', line 24 def next_page? load_nodes if before true elsif first limit_value < items.size else false end end |
#nodes ⇒ Object
18 19 20 21 22 |
# File 'lib/gitlab/graphql/pagination/active_record_array_connection.rb', line 18 def nodes load_nodes @nodes end |
#previous_page? ⇒ Boolean Also known as: has_previous_page
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gitlab/graphql/pagination/active_record_array_connection.rb', line 36 def previous_page? load_nodes if after true elsif last limit_value < items.size else false end end |