Wouldn’t have to adapt the way the frontend consumes the API either way, keeping track of the current list state? Or is that what the author meant, that you should always write your list UIs as if they consumed a paginated API?
Wouldn’t have to adapt the way the frontend consumes the API either way, keeping track of the current list state? Or is that what the author meant, that you should always write your list UIs as if they consumed a paginated API?
[{id: 1, …},…]
Then you can't easily add pagination without changing the structure of the response. Whereas if you have something like this:
{results: [{id: 1, …},…]}
then you can add in whatever other properties you need and this change can be made without immediately breaking any existing applications. Of course, it's still true that you'll have to rewrite the frontend to actually implement pagination, but it does do something for backward compatibility. You could probably still have old versions of the application at least display the first page of results without changes.
I think the general idea is to leave room in distributed APIs to add metadata later. It's not really just about potential pagination, but leaving yourself a way to add/change functionality later without updating all the clients in lockstep with the server (always awkward and there's never a way to pull it off 100% cleanly).
If you control both the client and the API, then pagination is something you can add in later. But setting up pagination early may make sense if the client isn't in your control.
The author gave the example of the an old mobile app that users don't update. The client is also out of your control if it's a public API that users call with whatever client code they choose.
That said, I'm not sure how setting up "fake" pagination is helpful if the client isn't already coded to use pagination responses from the server. So I'll have to assume the author means that any client you provide already has pagination logic built-in.
1: https://docs.github.com/en/rest/guides/traversing-with-pagin...