-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Regression: Ember Data tries to reload an already-loaded belongsTo
#7049
Comments
There are some differences in API-side implementations of JSON:API. Sometimes relationship types/ids are a part of the payload even when they are not loaded ( Other times, the data is not loaded at all, and rather a |
@Herriau 👋 I can start looking at this. If we have already set in stone the belongs-to relationship b/w a post and author by the time we follow the |
@Herriau if you PR a test I suspect recent improvements resolved this; however, I'd also note that this failure occurs because of ambiguity in the JSON:API spec that allows for related resource payloads to convey conflicting levels of information. When we process the belongsTo side in the example above we receive only a links object, which conveys that we don't know the data and still must load it. That payload is processed in isolation from the hasMany side, and so the lack of bi-directional full-linkage here (which the spec allows for) means that there is room for error. We should have been smart enough internally to still settle into the correct state, but the complexity of the former relationship-layer left a lot of odd outcomes on the table. It is much simpler now and if this is still an issue would be a simple fix. If you PR a test I'll fix it if it fails and merge it to prevent regression if it passes. |
… its data (#7049) (#7532) * add test (closes #7049) * adding links makes the test fail * update test and fix issue * fix test Co-authored-by: Chris Thoburn <[email protected]>
This is essentially exactly the same issue that was reported in #4099
Reproduction
Ember Twiddle: Here
If you have a console open while running this twiddle, you will observe the following output:
Expected output:
Description
If a
hasMany
relationship is loaded through includes (e.g.store.findRecord('author', 1, { include: 'posts' })
) then the inversebelongsTo
(e.g.post.author
) is still not considered loaded and consuming it will result in unnecessary additional requests.Versions
This behaves properly in EmberData 3.4.4, but it does not in EmberData 3.5.2, and all the way through the current release.
The text was updated successfully, but these errors were encountered: