to get a personalized navigation.
to get a personalized navigation.
Hi,
I thought that the returnvalue from the API "hasNextPage" indicates if there is a next page?
{query : useCompany(no: 4655191)
{associate(filter:{changedDateTime: {_gte:"2023-06-07T07:33:00.000"}}
after:"Ng==", first: 1) {pageInfo{hasNextPage endCursor}
items{name shortName employeeNo customerNo supplierNo employeeNo associateNo
changedDateTime createdDateTime addressLine1 addressLine2 companyNo
euVatRegistrationNo customerPriceGroup1 customerPriceGroup2 customerPriceGroup3 countryNo postCode postalArea languageNo}}}}
results in:
{
"data": {
"query": {
"associate": {
"pageInfo": {
"hasNextPage": true,
"endCursor": "Nw=="
},
"items": [
{
"name": "lars",
"shortName": "lars",
"employeeNo": 0,
"customerNo": 0,
"supplierNo": 0,
"associateNo": 33147,
"changedDateTime": "2023-06-07T07:37:00",
"createdDateTime": "2023-06-07T07:37:00",
"addressLine1": "",
"addressLine2": "",
"companyNo": "",
"euVatRegistrationNo": "",
"customerPriceGroup1": 0,
"customerPriceGroup2": 0,
"customerPriceGroup3": 0,
"countryNo": 0,
"postCode": "",
"postalArea": "",
"languageNo": 0
}
]
}
}
},
"extensions": {
"vbnxt-trace-id": "000000000000000034350908720dad17"
}
}
So getting the next page should have a result?
{query : useCompany(no: 4655191){associate(filter:
{changedDateTime: {_gte:"2023-06-07T07:33:00.000"}}
after:"Nw==", first: 1) {pageInfo{hasNextPage endCursor}
items{name shortName employeeNo customerNo supplierNo employeeNo
associateNo changedDateTime createdDateTime addressLine1 addressLine2
companyNo euVatRegistrationNo customerPriceGroup1 customerPriceGroup2
customerPriceGroup3 countryNo postCode postalArea languageNo}}}}
results in a empty page:
{
"data": {
"query": {
"associate": {
"pageInfo": {
"hasNextPage": false,
"endCursor": null
},
"items": null
}
}
},
"extensions": {
"vbnxt-trace-id": "0000000000000000ab879fc8f40165b7"
}
}
In combination of using Azure Datafactory with that it results in a endless-loop which makes Microsoft very happy about the cost/usage. (because Datafactory don't write data on empty pages and than we never get the information that the next page would not exist and we continue about asking this empty page)
Florian
Solved! Go to Solution.
A fix for this is in production. hasNextPage should now return the correct value in all cases.
I understand your concern and frustration. It's my fault for not documenting this properly. hasNextPage is not exhaustive but rather a hint that sometimes provides false positives. hasPreviousPage should work correctly. But for hasNextPage to always return the correct result we would have to retrieve the count of (filtered) rows from the backend which we don't do currently. So if you ask for N records but get < N, then it will properly tell you that there is no next page. But if you get exactly N, it will say there is a next page. However, fetching for the next page should return an empty set. I understand that is a request too many that incurs costs, but it shouldn't generate an infinite loop (like you seemed to suggest). We will investigate how to improve this.
You can solve this by internally trying to fetch pageSize+1 record, and if you get pageSize+1, then you drop the last record and know there is a next page. It's in most cases munch less expensive than doing a total count, but will still have a correct info about more pages.
With current implementation it's much better to not have a hasNextPage, since API users should never use it. They would all need to implement counting in the client or use the page+1 trick on the client if app does not need all pages at once
Yes, of course, that's also possible. Thank you. But if this could be fixed maybe others won't spent time on finding solutions around the problem 🙂
And: no stress, I get solved this by checking the number of rows in the result instead, but the hasNextPage is useless
Copyright © 2022 Visma.com. All rights reserved.