feat(app): Added pagination response to API ResponseTrait#9758
feat(app): Added pagination response to API ResponseTrait#9758lonnieezell merged 5 commits intocodeigniter4:4.7from
Conversation
Updated deptrac.yaml to allow the API layer to also depend on:
michalsn
left a comment
There was a problem hiding this comment.
Seems there is a small problem with the user guide, but other than that, it looks great!
neznaika0
left a comment
There was a problem hiding this comment.
paginate() has a bug #8904.
Can we decide on the main api? Each request is now a separate standard.
Because each request can have links, descriptions, meta, and errors... Plus, it's useful when a recursive object ($user->post->tags[0]->name) contains meta.
Have you considered the json:api? https://jsonapi.org/format/
I'm not sure I follow 100%.
I am familiar with jsonapi and it is a more complex solution than I believe is appropriate for CodeIgniter to support out of the box. |
|
json:api is heavy at this stage. I wanted to find out the full API specification for the framework. |
Description
The first in a handful of PRs to bring our API features to a more usable, modern place.
This adds a new method to the API\ResponseTrait: paginate(). This takes the model or query builder and returns a structured array with meta information and a series of links easily usable by javascript frontends.
This also follows best practices and RFC 8288 by setting the Links header with the same links in our response, and the X-Total-Count header with the total number of results. This provides information for both the human-readable portion used in frontend work, and with some machine readable information in the headers that is much easier and less error prone to be parsed.
Checklist: