You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
API Platform version(s) affected: 4.0.4
Cursor Pagination with $after, etc... using graphql seems to not work in Laravel.
I think there are 2 Issues with it:
It is not really a cursor based pagination (see this issue)
It does not seem to be accounted at all (at least not in the laravel implementation) - this might be due to how laravel simplePaginate works (assuming that cursor based pagination is considered "partial" pagination, which it isn't automatically) and that there is no offset option for that.
A potential fix could be using laravels cursorPaginate function, but some serialization and deserialization of the cursor would need to be also added for this to work. Also GraphQL operations making use of that, should automatically be considered partial paginations.
I will try to open a PR for this.
The text was updated successfully, but these errors were encountered:
@soyuka I now have time to implement this laravel...but laravel only supports the following for cursor pagination:
Number of Items (first)
Current Cursor (after)
Current options like: befre, first, last would not be available.
Or at least not directly. Before could be implemented by returning the cursor of the previous page however it would probably need a different name since nItems (e.g. 10) before cursor "x" would mean 10 cursor items AFTER x
I do not know about non cursor pagination and symfonys / doctrine way tbh and wouldn't therefore want to fiddle arround there. There exists this PR for it, all i would do is take the CursorPaginatorInterface from there so if that PR is merged it will work together with this.
But to archive this correctly (and in a simple manner) i would need to extend TypeBuilder and FieldsBuilder for Laravel inside the src/laravel directory (to avoid adapting the graphql package and it's contents) since getCursorBasedPaginationFields and getGraphQlPaginationArgs need to work differently and only return "first" and "after" as possible options in the schema. This can be done easily (i think lol) since we can then inject it in the ApiPlatformServiceProvider..which sort of already happens.
Is that okay to do or do you have something different in mind?
Ah never mind TypeBuilder and FieldsBuilder are final. Would need to change that, or the files directly, and see how it works out in the symfony/doctrine universe...so yeah you would need to decide what to do
API Platform version(s) affected: 4.0.4
Cursor Pagination with $after, etc... using graphql seems to not work in Laravel.
I think there are 2 Issues with it:
simplePaginate
works (assuming that cursor based pagination is considered "partial" pagination, which it isn't automatically) and that there is no offset option for that.A potential fix could be using laravels
cursorPaginate
function, but some serialization and deserialization of the cursor would need to be also added for this to work. Also GraphQL operations making use of that, should automatically be consideredpartial
paginations.I will try to open a PR for this.
The text was updated successfully, but these errors were encountered: