-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cursor pagination does not support hashids #201
Comments
Thanks for reporting this - it is indeed a bug. There's already a PR in the cursor pagination package relating to this, and my comment on it here explains that I need to amend that package so the ID field is injected into the cursor paginator. I'll prioritise this for a fix, probably in the next week or two. |
@othneildrew I think I've solved this but it would be good if you could give it a go. To give it a go, run the following: composer require "laravel-json-api/cursor-pagination:dev-feature/id-decoding" To use in your schema, you would just need to do the following: public function pagination(): CursorPagination
{
return CursorPagination::make($this->id());
} |
@lindyhopchris My apologies that this took me soon long to review. But I'm happy to report that it works wonderfully, thanks so much for fixing this! The only missing piece I think is the validation of page params now. For example, something like this would no longer pass validation checks: 'page.after' => 'filled|string|exists:lessons,id',
'page.before' => 'filled|string|exists:lessons,id', |
Yeah good point, I need to add some |
Closing in favour of #237 - that documents that I need to add things to make validating resource IDs a lot easier. |
Having setup and followed the docs to enable hashids, I've discovered that when using hashids with Cursor Pagination, the meta page info uses the ids from the DB column.
_Trying without validating page query. I get "the selected page.after is invalid with proper validation _
The text was updated successfully, but these errors were encountered: