pre-rfc: Sync relationships without data should not be treated as loaded
When you have a relationship with:
-
async: false - server includes
link - server does not include
data
You get the warning:
You pushed a record of type 'organization' with a relationship 'subscriptions' configured as 'async: false'. You've included a link but no primary data, this may be an error in your payload. EmberData will treat this relationship as known-to-be-empty.
But it's not an error, it's on purpose and it's perfectly legal. When data is not present, it's a violation of JSON:API spec to treat the relationship as known-to-be-empty. It should be treated as unloaded.
Like any synchronous relationship that is unloaded, trying to access it should generate an error, so that the developer realizes they need to either sideload it or use the reference API to fetch it explicitly.
Unfortunately the reason this is so is because when we improved our JSON:API capabilities a few years ago it turned out a lot of folks were relying on sync relationships without a data member being treated as if they were empty. It's been on my mind to clean that up for some time but it's a "lift" in the sense that it would change the behavior in a negative way for a significant group.
I believe a compounding factor was that a number of popular JSON:API api framework implementations would serialize empty relationships without a data member by default. Some in all cases, some just when a link was possible.
Would happily accept an RFC to change this.
Probably a path forward here would be for the json-api serializer to absorb the cost of adding in an empty data member with a deprecation, while the store would then go by the better expectation (no data member means needs to be loaded).