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

Sparse Fieldsets

Open olragon opened this issue 2 years ago • 7 comments

https://jsonapi.org/format/#fetching-sparse-fieldsets

A client MAY request that an endpoint return only specific fields in the response on a per-type basis by including a fields[TYPE] parameter.

Can we implement this usage pattern?

olragon avatar Oct 01 '21 16:10 olragon

Hi @olragon,

It is currently not supported and there is no scheduled milestone for this feature yet. Leaving the issue open to see, if more developers would need that functionality.

alexzarbn avatar Oct 04 '21 14:10 alexzarbn

This would be really handy to have. Would you be open to a PR?

glennjacobs avatar Jan 04 '22 10:01 glennjacobs

Hi @glennjacobs,

Sure, PRs are always welcome ~

alexzarbn avatar Jan 07 '22 15:01 alexzarbn

@alexzarbn

Just want to also add that this feature would be immensely useful, especially if you add support in the JS library. Would cut down a lot on having to write different controllers/resources/or other logic that removes certain fields from a search.

rossity avatar Feb 07 '23 16:02 rossity

Maybe someone might find it interesting. https://github.com/emeGuan/laravel-resources It is not a substitute for this fantastic Laravel Orion library, far from it. But it can be useful for someone who wants to build their API using https://laravel.com/docs/10.x/eloquent-resources Regards.

emeGuan avatar Feb 22 '23 11:02 emeGuan

@alexzarbn @olragon

I created a simple implementation of this.

https://github.com/tailflow/laravel-orion/pull/226 https://github.com/tailflow/laravel-orion-ts/pull/36

Edit: updated them to use sparse fieldsets.

rossity avatar May 17 '23 20:05 rossity

This should be mentioned in the RADME along with other essential functionality that is not available in this package.

cirrusmostar avatar Oct 07 '23 11:10 cirrusmostar