Skip to content
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

embedded items should be accessible by key #486

Open
beuss opened this issue Nov 27, 2023 · 2 comments
Open

embedded items should be accessible by key #486

beuss opened this issue Nov 27, 2023 · 2 comments

Comments

@beuss
Copy link

beuss commented Nov 27, 2023

Current _embedded handling put embedded resources in cache. This causes several issues

The first one is that when using NeverCache, if you follow Ketting's guidelines and use follow/followAll to get embedded resources, you'll end up with n additional HTTP requests performed, defeating the whole purpose of embedding. Moreover, those fetches will return you the representation available on self-link, which might be totally different from what you expect, as the spec states:

Embedded Resources MAY be a full, partial, or inconsistent version of the representation served from the target URI.

The alternative is to use getEmbedded, but there's a scary warning and results might here again not be as expected (since a subsequent fetch without embedded resources would wipe them out). Moreover, even when using getEmbedded, you cannot filter which embedded you'll get back since there's no rel filtering.

In its current current approach, it looks very hard to use embedded properly when using ketting. The issues looks related to cache handling but there's no way to disable caching (NeverCache is not a switch-off per se).

@evert
Copy link
Collaborator

evert commented Nov 27, 2023

hey @beuss , does ShortCache works for you? NeverCache only really exists for niche cases like testing.

If not, i would be interested to understand your use-case better. It's true that the link embedded resource can disappear if we got a whole new representation of that resource that no longer embeds them, but if you have a previous State, that state is supposed to be mostly immutable.

@beuss
Copy link
Author

beuss commented Nov 27, 2023

Well ShortCache may adds other issues :)
If embedded is not the same representation as the self endpoint, you end up poisoning it. Let say you've a customer representation where you embedded address summary (let's say zipcode and city only) to display it on level 0 form, its self-link will be say /address/1.
From this form you offer a link to edit the address, it fetches /address/1, but if user clicks too fast you hit cache and get the partial representation (from previous embedded)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants