-
-
Notifications
You must be signed in to change notification settings - Fork 234
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
API Resource pagination in closures missing metadata #298
Comments
Hi. I was able to reproduce this. Case 1Not working. ❌ Your case. return Inertia::render('App/Users', [
'1test' => function () {
return [
'users' => UserResource::collection(User::paginate(5)),
];
},
]); Case 2Is working. ✅ This is the same approach as in the shared data docs. return Inertia::render('App/Users', [
'1test' => [
'users' => function () {
return UserResource::collection(User::paginate(5));
}
],
]); Case 3Is working. ✅ Standard approach. return Inertia::render('App/Users', [
'1test' => function () {
return UserResource::collection(User::paginate(5));
},
]); @claudiodekker I assume that this is not is an intended behavior? I'll send a PR now and mark it is draft, because I didn't add any new tests. Old still pass. In case it is mergable I am happy to add extra tests fior it. @gilbitron if you want please test the following PR and let me know if this solves your issue. |
@NickSdot Thanks for the detailed reproduction 👍 |
@claudiodekker added test and changes as requested. Ready for review. |
When using pagination with an API Resource inside a closure, the pagination object is missing the metadata. This seems to be a similar issue to #28 but happens specifically when using closures for partial reloads. For example:
If I don't use a closure or if I don't use the API resource class, the full paginated object (including metadata) is returned in the response.
The text was updated successfully, but these errors were encountered: