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

inverse relationships not set up when pushing jsonapi blob with polymorphic model #5267

Closed
BryanCrotaz opened this issue Nov 29, 2017 · 4 comments

Comments

@BryanCrotaz
Copy link
Contributor

BryanCrotaz commented Nov 29, 2017

Single source of truth isn't working for polymorphic relationships.

Push a hasMany with a descendant model. You'd expect that the matching belongsTo on the descendant model points back to the parent model. Instead it's null.

This works if the child model is the type specified in the hasMany, but not if it's a descendant model.

store.push({
  data: { post with relationship to descendant comment1 },
  included: { descendant comment1 with missing post relationship }
})
post.get('comments') => [comment1]
comment1.get('post') => **null**

Workaround: add post relationship into comment1 in jsonapi

Working on a PR with test

@BryanCrotaz BryanCrotaz changed the title inverse relationships not set up when pushing jsonapi blob inverse relationships not set up when pushing jsonapi blob with polymorphic model Nov 30, 2017
BryanCrotaz added a commit to BryanCrotaz/data that referenced this issue Nov 30, 2017
@BryanCrotaz
Copy link
Contributor Author

Test added in PR #5268

@BryanCrotaz
Copy link
Contributor Author

BryanCrotaz commented Nov 30, 2017

@stefanpenner I'm not sure of the best way to fix this. The relationship-payload cache is keyed on baseClass:relationship so the entry isn't being found when you search for descendant:relationship.

We could add multiple cache entries for each of the different descendants, but I'm not sure how to discover them.

@BryanCrotaz
Copy link
Contributor Author

I think I found a way... see PR for details

@bmac
Copy link
Member

bmac commented Mar 5, 2018

I believe this has been resolved by #5230. Feel free to reopen if it is still an issue.

@sly7-7 sly7-7 closed this as completed Mar 9, 2018
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

3 participants