-
-
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
Ember Data tries to reload an already-loaded belongsTo
#4099
Comments
Simplified reproduction: http://emberjs.jsbin.com/qetidomara/1/edit?html,js,output There shouldn't be additional requests to |
I think we need to differentiate between loaded and unloaded records ( |
I don't think this is specific to belongs-to relationships. I've been experiencing the same behavior with has-many. |
Posting to follow. Also see this. |
This should have been solved since #3762 – would you be able to confirm? |
@wecc this appears to be unsolved based on helping someone in Slack this evening. Will likely try to dig in this week. |
I'm having what appears a pretty similar experience, @runspired and i actually debugged a bit. However i'm finding that if i use a @samselikoff could you check that on your end as well? |
I'm running a Rails JSONAPI-Resources back-end with Ember-Data 2.13. No particular customizations to the Ember-Data adapters or serializers or the JSONAPI-Resources ValueFormatters. No Ember canary flags enabled. I use the 'include' directive extensively in my When I upgrade past Ember-Data 2.13 (up to Ember-Data 2.14 -> 2.17 at time of writing this message) I observe a plethora of additional server api request for relationship data due to |
Having a similar problem. This works as expected without triggering unnecessary queries:
But when records are already loaded before (without including associations):
It triggers a query for each |
I'm having the same issue I can eager-load a belongsTo relationship successfully and i see the records in Ember data (in the developer tools plugin). But as soon as I try to use those records it attempts to reload the data from api. This was in 2.18.0. Following @nadnoslen and downgrading to 2.13.0 seems to fix it |
Can anyone confirm this is actually fixed? I've upgraded Ember Data to the latest version (3.2.0-beta.2) but am still getting the exact same behaviour @jvenezia is describing. |
@elonmulder @adamlawson @jvenezia it’s likely your payloads aren’t specifying the relationship correctly. |
Thanks @runspired! I just finally got around to upgrading from Thank you Ember-Data team. |
I can confirm this is still an issue with Downgrading to In both scenarios includedResource properties are being called in the template like: |
I'm currently trying to upgrade Ember Data from 2.11.1 to 3.5 and having this exact problem. Going back to 3.2.0 Doesn't fix the problem for me. @runspired you suggested that perhaps the problem is that the payloads aren't specifying the relationship correctly. Is there any documentation out there that specifies the exact payload/json structure? Our project uses a serializers/application.js file, so I'm hoping that I can just adjust the normalizeResponse function to ensure that the JSON is formatted correctly? |
Hey @skthr, Here's the blurb on relationships and here are some simple examples Make sure you're looking at v1.0 of the spec. I say this because a release candidate of v1.1 has been published. |
@nadnoslen @skthr the reload issue is fixed through 3.4, but may be present again 3.5. |
Thanks @nadnoslen and @runspired Going back to 3.4 didn't help so I'm pretty confident that there is something wrong with the payload (at least that seems like the best place to look). If I compare our payloads to the JSONAPI spec I'm sure I'll find the issue eventually. Much appreciated. I'll update when I make some progress. |
Ember data models:
I'm using a JSON:API backend (and adapter on the frontend). My application route (with the
ds-finder-include
feature flag enabled):which correctly sends out the request
which responds with https://gist.github.com/samselikoff/20012aa58075db6124de.
In my application template,
{{post.author.name}}
correctly displays the author's name, but triggers n+1 requests to/posts/1/author
,/posts/2/author
and so on. So, the inverse relationship is loaded correctly in Ember Data, but ED is still making an ajax request.@wecc tracked it down to
data/addon/-private/system/relationships/state/belongs-to.js
Lines 120 to 146 in 5826230
The text was updated successfully, but these errors were encountered: