-
Notifications
You must be signed in to change notification settings - Fork 49
Hinting of embedded resources #118
Comments
In our project we do exactly like you propose in your last solution. Resources that are not embedded are linked. This seems to work very well in practice. We also took this a step further. Resources that are already rendered once in the response will not be rendered again in another resource in the same response. For example. We render a resource collection. Right now we solve this with some customization of the We can do this because on the client side we cache the json objects by their respective This delivers a performance increase since on the server we only need to render each entity once and our This is implementation is according to the caching specs in hal section 8.3. We first tried to solve this in the
Which virtually comes down to our I would be interested in implementing such solution this part of the library. |
@nobesnickr |
This repository has been closed and moved to laminas-api-tools/api-tools-hal; a new issue has been opened at laminas-api-tools/api-tools-hal#16. |
I've been struggling with a problem for some time regarding how relationship are handled on entities, specifically when embedded into a resource. The problem (and I assume it is a fairly common one) is how to provide relationships in a sane and dependable way without returning the entire (or most of the) database in embedded resources (and dealing with looping recursion problems) or always needing to fetch relationships. HAL spec is a bit fuzzy on how _embedded resources are supplied which makes it harder to create a dependable abstract consumers. For example, HAL Clients don't know if the non-rendered entity is actually rendered or not (or is just a link) or whether it is a full or partial rendering. The first case is an easier problem to solve abstractly and a few suggestions are below.
For the sake of example lets assume the following:
** person --> one-to-many (bestFriend) --> person
false
We can either:
Link Only:
Partial Resource:
I've created PR #118 to show an example of how we can enabling linking insteading of embedding and would love to get feedback on how others are solving this kind of issue, and/or if I should focus time on building out one of the above potential solutions.
The text was updated successfully, but these errors were encountered: