7 ms·
This seems similar to how Eloquent (Laravel's ORM) will, by default, make separate IN queries when you ask for a collection plus its relationships (instead of u
by euoia 3y ago
This seems similar to how Eloquent (Laravel's ORM) will, by default, make separate IN queries when you ask for a collection plus its relationships (instead of using a JOIN).
I have thought about how you might return normalised data to your front-end and, with support from a front-end library, rebuild the object relationships so you can access them naturally.
I looked into JSON:API and indeed there is a Laravel library for working with JSON:API https://github.com/laravel-json-api/laravel https://github.com/laravel-json-api/laravel.
One place I got stuck with JSON:API is that support for updating a row and its relationships in a single API request seems to have been kicked around for a while and is unresolved:
https://github.com/json-api/json-api/issues/795 https://github.com/json-api/json-api/issues/795
There is an atomic operations extension:
https://jsonapi.org/ext/atomic/ https://jsonapi.org/ext/atomic/
But is currently unsupported by laravel-json-api:
https://github.com/laravel-json-api/laravel/issues/39 https://github.com/laravel-json-api/laravel/issues/39