-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(app): Added pagination response to API ResponseTrait #9758
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
Conversation
Updated deptrac.yaml to allow the API layer to also depend on:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems there is a small problem with the user guide, but other than that, it looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: