Add ExternallyPaginatedArrayConnection for GraphQL
What does this MR do?
This adds ExternallyPaginatedArrayConnection
, and is extracted from !21802 (merged).
We sometimes need to fetch data from a third-party and return that via GitLab by the means of GraphQL. That data may be paginated within the third-pasty system (say via cursor pagination).
In order to return pagination field attributes, such as hasNextPage
(https://docs.gitlab.com/ee/api/graphql/getting_started.html#pagination) we need to create a way to externally-paginated resources to these values manually. This is because we are not doing the pagination (say from an ActiveRecord array etc) on our end.
This allows creating an array while also providing optional cursor details:
array = Gitlab::Graphql::ExternallyPaginatedArray.new(1, 6, 2, 3, 4, 5)
=> [2, 3, 4, 5]
array.previous_cursor
=> 1
array.next_cursor
=> 6
Screenshots
Does this MR meet the acceptance criteria?
Conformity
Edited by Mayra Cabrera