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

pre-rfc: Sync relationships without data should not be treated as loaded #7584

Open
ef4 opened this issue Jun 4, 2021 · 2 comments
Open

Comments

@ef4
Copy link
Contributor

ef4 commented Jun 4, 2021

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.

@runspired
Copy link
Contributor

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.

@runspired
Copy link
Contributor

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).

@runspired runspired changed the title Sync relationships without data should not be treated as loaded pre-rfc: Sync relationships without data should not be treated as loaded Sep 10, 2023
@runspired runspired added this to the Public Graph API milestone Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: needs champion
Status: Quest Issues
Development

No branches or pull requests

2 participants