laravel-orion icon indicating copy to clipboard operation
laravel-orion copied to clipboard

feat: add select fields to query params

Open kefivitch opened this issue 1 year ago • 2 comments

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

kefivitch avatar Oct 26 '23 08:10 kefivitch

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.

alexzarbn avatar Nov 02 '23 08:11 alexzarbn

Okay, I gonna focus on ading more tests to it and change the logic to QueryBuilder in upcoming days, WORK IN PROGRESS...

kefivitch avatar Nov 12 '23 15:11 kefivitch

Closing due to inactivity.

alexzarbn avatar Mar 30 '24 10:03 alexzarbn