Cursor-based pagination with GraphQL.
dataSources
, dataPools
, metrics
, and applications
).
To page forward, the first
and after
parameters are expected:
Parameter | Description | Default | Maximun | Required |
---|---|---|---|---|
first | Indicates the number of items to be returned. | 10 | 100 | No |
after | The cursor that indicates the position where to start fetching items forward. The result will not include the item in the after cursor. | most recent | — | No |
last
and before
parameters are expected:
Parameter | Description | Default | Maximun | Required |
---|---|---|---|---|
last | Indicates the number of items to be returned. | 10 | 100 | No |
before | The cursor that indicates the position where to start fetching items backward. The result will not include the item in the before cursor. | most recent | — | No |
first
is provided, the most recent specified number of items will be returned.last
is provided, an empty list is returned.after
or before
are provided, the default count of items before or after the cursor will be returned.after
and before
are provided, a 400 Bad Request is returned.first
and before
are provided, a 400 Bad Request is returned.last
and after
are provided, a 400 Bad Request is returned.PageInfo
response objectdataSources
, dataPools
, metrics
, and applications
) will return a PageInfo
object.
The PageInfo object has the following properties:
pageInfo
response object described above, GraphQL cursor-based pagination makes use of Connections and Edges.
edges
and pageInfo
. The property pageInfo
is an instance of the PageInfo
object described above.
cursor
value when returning an object and the pageInfo
object when returning the list without changing the base objects.
Let’s look at an example of how these objects look like in the Metrics GraphQL Schema.
A Metric connection has the pageInfo
object and a MetricEdge
array.
cursor
and the actual Metric
object.
getAllMetrics
query would be called with either first
and after
or last
and before
and would return a MetricsConnection
.
first
to 25 in our query. This will return the first page of results. Make sure to request pageInfo
and edges
to be included in the response.
first
to 25 and after
to the value of the endCursor
we got in the MetricsConnection response. This will return the second page of results.