fix: remove hydra:next when no items would be returned in the next cursor pagination page#6477
Conversation
| $data['hydra:view']['@id'] = IriHelper::createIri($parsed['parts'], $parsed['parameters'], urlGenerationStrategy: $urlGenerationStrategy); | ||
|
|
||
| if (false !== $lastObject && \is_array($cursorPaginationAttribute)) { | ||
| if (false !== $lastObject && \is_array($cursorPaginationAttribute) && $pageTotalItems >= $itemsPerPage) { |
There was a problem hiding this comment.
when $pageTotalItems == $itemsPerPage we want to show hydra:view? Can you test this? I thought that with a cursor we did not know the amount of total items (no count)?
There was a problem hiding this comment.
We did test it out, we have it live in our production environment. This isn't perfect because it still could return no results on the next page, however, it prevents an empty page from showing hydra:next.
The logic is that with cursor pagination if you no longer have results on a page, the next one won't either because you are doing a less less than or greater than some identifier. Because it's only a comparison like that if it doesn't return enough results we can be certain the next page will return none.
There was a problem hiding this comment.
would you be able to add a test for this?
There was a problem hiding this comment.
Sorry I haven't gotten around to adding a test here. It isn't forgotten though.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
It still needs to be resolved. I've not had time to add the proper tests to the PR unfortunately. |
|
Hi, are you still interested by this PR ? Do you have time to resolve the conflict/comment ? |
…rsor pagination page
84e12d6 to
09d235e
Compare
|
I'm not a huge fan of this as it adds more computation then needed. I think that using JSON-LD users would just dereference and see an empty page which is probably fine. |
When using cursor pagination,
hydra:nextis currently always set even when it wouldn't return any results.