-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hinting of embedded resources #16
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. Originally posted by @Wilt at zfcampus/zf-hal#118 (comment) |
@nobesnickr Originally posted by @LeeRoi at zfcampus/zf-hal#118 (comment) |
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.
Originally posted by @nobesnickr at zfcampus/zf-hal#118
The text was updated successfully, but these errors were encountered: