laravel-orion
laravel-orion copied to clipboard
feat: add select fields to query params
What ?
- This feature allows us to choose fields while fetching an index using
fields
query parameter.
How to use ?
We can simply add fields array to query params. Each index of the fields array represents a relation name. For example,
/api/posts?fields[posts]=title,user_id&fields[user]=id,name&include=user
/!\ Good to know:
Make sure you add the relation to the include
query params, and the keys to the select fields.
What's next ?
If this PR got accepted and merged, I will create a PR for the TS repo
Happy coding
Hi @kefivitch,
Thank you for the PR!
I would suggest to move the logic into QueryBuilder
class, see here. Also, please ensure that selecting fields of nested relations is working as intended.
Okay, I gonna focus on ading more tests to it and change the logic to QueryBuilder in upcoming days, WORK IN PROGRESS...
Closing due to inactivity.