Graphql cursor based pagination does not work with sorting
I have a headless app which uses AEM Cloud to serve the data with the following persisted graphql query:
query (
$locale: String!
$path: ID!
$sort: String
$first: Int
$after: String
) {
pagePaginated(
_locale: $locale
filter: {
_path: { _expressions: [{ value: $path, _operator: STARTS_WITH }] }
}
sort: $sort
first: $first
after: $after
) {
edges {
node {
_path
__typename
title
description {
plaintext
}
}
cursor
}
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
}
}
I am getting an error with cursor based pagination whenever both the sort and after variables are present. When either is used independently, the query works as expected, such as either of these examples:
WORKS (But no sorting):
{
"locale": "en",
"sort": "",
"first": 2,
"path": "/path/to/my/content/",
"after": "bnVsbAo5YTM3ZWVlMi1hM2ZjLTQ4N2QtYmY4Yi1kZTMzMzg5YTAwNWI="
}WORKS (But no cursor supplied for pagination):
{
"locale": "en",
"sort": "title ASC",
"first": 2,
"path": "/path/to/my/content/",
"after": ""
}
THE PROBLEM CASE
When both sort and after variables are supplied.
THROWS ERROR:
{
"locale": "en",
"sort": "title ASC",
"first": 2,
"path": "/path/to/my/content/",
"after": "bnVsbAo5YTM3ZWVlMi1hM2ZjLTQ4N2QtYmY4Yi1kZTMzMzg5YTAwNWI="
}
This will return the following error:
{
"errors": [
{
"message": "Exception while fetching data (/pagePaginated) : Start cursor not found in supplied data:bnVsbAo5YTM3ZWVlMi1hM2ZjLTQ4N2QtYmY4Yi1kZTMzMzg5YTAwNWI=",
"locations": [
{
"line": 13,
"column": 3
}
],
"path": [
"pagePaginated"
],
"extensions": {
"classification": "DataFetchingException"
}
}
],
"data": null
}
Am I missing something, or is this a bug in Adobe's implementation of GraphQL?
Please advise.


