emberjs / data

WarpDrive is a lightweight data library for web apps — universal, typed, reactive, and ready to scale.
https://api.emberjs.com/ember-data/release
MIT License
3.04k stars 1.33k forks source link

[DEPRECATION] missing data for `sync` relationships should not be considered `empty` #8816

Closed runspired closed 1 year ago

runspired commented 6 years ago

Currently, if a synchronous relationship receives a payload containing no information about it's state, we initialize the relationship as if it were canonically empty. This is incorrect, as we don't actually know the state (having received no information about it), which leads to us being unable to utilize reference.load() which would otherwise allow a user to utilize findBelongsTo/findHasMany to load the relationship manually. While users of references may use reference.reload() instead, we should also firm up our API expectations here, as this is a place wherein we deviate from json-api.

This deprecation would warn when this scenario is encountered. Once the deprecation lifecycle is complete, this deprecation would turn into an assertion, as the relationship is in an invalid state. For additional context, see this bugfix commit that restored this behavior after it was unintentionally broken/discovered: https://github.com/emberjs/data/pull/5533/commits/850bdf2688fe9e9cbfb4f381cb9d460acf7150f7

runspired commented 5 years ago

We improved the behavior here slightly by only considering missing relationship data to be empty when no previous information has been received: https://github.com/emberjs/data/pull/5880

Would still love a champion for this deprecation so we can help folks avoid bugs when their payloads are less complete than they should be.

wagenet commented 2 years ago

I'm closing this due to inactivity. This doesn't mean that the idea present here is invalid, but that, unfortunately, nobody has taken the effort to spearhead it and bring it to completion. Please feel free to advocate for it if you believe that this is still worth pursuing. Thanks!

runspired commented 2 years ago

This is still pretty important as it's one of our more serious misalignments between spec's and what we do. It's also low hanging fruit :)

runspired commented 1 year ago

closing in favor of https://github.com/emberjs/data/issues/7584