debian-mirror-gitlab/lib/gitlab/graphql/pagination/externally_paginated_array_connection.rb

30 lines
612 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
# Make a customized connection type
module Gitlab
module Graphql
2020-04-22 19:07:51 +05:30
module Pagination
class ExternallyPaginatedArrayConnection < GraphQL::Pagination::ArrayConnection
2020-03-13 15:44:24 +05:30
def start_cursor
2020-04-22 19:07:51 +05:30
items.previous_cursor
2020-03-13 15:44:24 +05:30
end
def end_cursor
2020-04-22 19:07:51 +05:30
items.next_cursor
2020-03-13 15:44:24 +05:30
end
def next_page?
end_cursor.present?
end
def previous_page?
start_cursor.present?
end
alias_method :has_next_page, :next_page?
alias_method :has_previous_page, :previous_page?
end
end
end
end