Limited or paginated GraphQL query results
Because the number of results of a mashup query may turn out to be very large, you can set a limit on the maximum number of returned items per call, and paginate them.
You can limit how many items (or Component Presentations, when using a
componentPresentations() call) to return per call, and use the cursor field to paginate. To do so, insert a first: property directly after the filter expression, set to the maximum number of results you want to see returned:
{
items(
filter {
FILTEREXPRESSION
},
first: MAXIMUM,
) {
RETURNEDFIELDS
}
}
where MAXIMUM is the maximum you want to set. Make sure to include the cursor property in RETURNEDFIELDS.
Check the value of the
cursor property in the last result you get back, and specify this value in your following call:
{
items(
filter {
FILTEREXPRESSION
},
first: MAXIMUM,
after: CURSORID
) {
RETURNEDFIELDS
}
where CURSORID is the value of the cursor property of the last item returned. This way, the query returns the next page of results. Again, make sure to include the cursor property in RETURNEDFIELDS to be able keep paginating.