aimeos / ai-client-jsonapi

Aimeos frontend JSON API
GNU Lesser General Public License v3.0
28 stars 6 forks source link

Including nested resources #19

Closed tobbe-j closed 1 year ago

tobbe-j commented 2 years ago

Would it be possible to allow including nested resources as defined in the jsonapi specification.

For example, when having a single product page where we would also want to display some information about the supplier, it's currently only possible to include the supplier resource /jsonapi/default/product?id=1&include=supplier. However, we would also probably want to show the supplier image and description which currenlty requires a new (and dependent) request /jsonapi/default/supplier?id=<id from previous request>&include=text,media.

The jsonapi spec allows nested includes, which would mean that this scenario could be solved via /jsonapi/default/product?id=1&include=supplier,supplier.text,supplier.media. This would greatly simplify a lot of data fetching when using the api.

Although I'm not too familiar with the aimeos codebase yet it seems like this should be possible to implement in the aimeos data architechture, simply iterating over the different domains that need to be included and searching for the related resources.

aimeos commented 2 years ago

It will require some changes in the managers to handle that correctly but it should be possible. We will try to implement the necessary changes in 2022.x

tobbe-j commented 2 years ago

Nice, sounds good and looking forward to the possible improvements!

Is it ok to leave the issue open until there is any development on it or should I close it?

aimeos commented 2 years ago

Yes, please

aimeos commented 1 year ago

Finally, the necessary changes have been done and it's now possible to use domain specific nested resources according to the JSON:API specifiction, e.g. include=product.text,product.media,supplier,supplier.address