-
-
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
Polymorphic relationships that are sideloaded do not materialize the relationship the first time they are pushed into the store (unless the relationship has been "primed" with a .get beforehand) #5313
Comments
I seem to have the same problem with polymorphic relationships, if anyone's got an idea, workaround or anything. |
FYI, it looks like this is a regression from 2.14.x+, it works in 2.13.2 Here's the same twiddle, with just ember-data version downgraded to 2.13.2 |
This should be resolved now since #5230 landed |
@runspired @bmac this is actually not resolved with #5230 @runspired as per our discussion on slack, the polymorphic mixin case is still not working. Here is an updated twiddle using 2.18.2, that still exhibits the same regression: https://ember-twiddle.com/a33872a20ef7b7279c6a6566132564cb?openFiles=twiddle.json%2C |
@kjhangiani ah, I forgot this was the mixin-specific issue |
@kjhangiani I added it to my bucket of issues to dig in and add tests for today. |
thanks @runspired - I'm interested in seeing how you write the tests when you do so - I wanted to try to write the test cases, but I got a little lost in the codebase, especially for this mixin case |
just ran into this footgun again on a different polymorphic model - has there been any movement on this @runspired ? Just tested [email protected] and the bug still exists: https://ember-twiddle.com/a33872a20ef7b7279c6a6566132564cb?openFiles=twiddle.json%2C Our workaround is pretty hacky right now but it works
(basically we use the store to filter by type and id instead of using a hasMany) |
@kjhangiani I'd like to get some tests in place for it, easy fix if we have them. It's likely a non-issue on the |
We should still add tests for this, but I'm going to close this as ember-data since 3.5 has not had lazy relationships and as such would not exhibit this issue. |
We have a polymorphic relationship with the following approximate structure:
the response to
store.findRecord('post', 1, { include: ['comments'] })
returns:however,
store.peekRecord('post', 1).get('comments')
is null after this API request completes.Interestingly, if I first do:
store.findRecord('post', 1)
(without an include for comments), then callstore.peekRecord('post', 1).get('comments')
, this seems to "prime" the relationship so to speak, so that later, if comments are loaded from the API, either via a sideload, or directly from the comments endpoint, this relationship will correctly update.This doesn't seem to be the case in other hasMany / belongsTo sideload situations - it seems to be due to the polymorphic nature of comments.
Here's a repro twiddle on the latest version of ember-data:
https://ember-twiddle.com/a33872a20ef7b7279c6a6566132564cb?openFiles=controllers.application.js%2C
I also tried the polymorphic PR by @runspired here: #5230 but this did not resolve the issue in our app.
Is this a bug? Is there a workaround?
The text was updated successfully, but these errors were encountered: