EmilMoe
5 months ago
365
3
Laravel

Require item in API even when not on the paging

Posted 5 months ago by EmilMoe

My problem is when paging my API requests it happens rather often that an object which has a reference to another is intersected.

For example I call api/books/1 on that page I already loaded api/authors. But the author associated to Book:1 isn't in on the first authors page, maybe it indexes 10 per page and this is Author:20.

Now my selects and lists cannot properly display it as they cause a mismatch where the author isn't in the list.

My question is how this is best solved? I have played with some parameters such as &include=20 to force an extra added, but I feel it's bad design and then users could index everything by running many include queries.

Please sign in or create an account to participate in this conversation.