You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently trying to load quite a few records and their related records in one request. Sometimes Ember Data seems to fetch related records even though they were included in the request. Another weird thing is, that switching to a different model it seems like reloaded models change or unset their relations.
Visiting this link, you'll see a list of Playlists, clicking one of those fetches one of those playlists with all their related data in one request (using mirage). On the first visit, it seems to make unnecessary requests to already included records of PlaylistTrack.
Switching between Playlists also seem to have some weird behavior, where Track relations to Artist seem to unset them on subsequent requests.
The text was updated successfully, but these errors were encountered:
They contain a tracks relationship with no records, and because they get parsed after the track records (because they are after the track records in the includes array) Ember Data think their info is more up to date and unsets the artist belongsTo on the track side of the relationship.
When I remove the tracks hasMany from mirage/models/track.js mirage stops sending the empty array and Ember Data appears to start behaving normally again.
Debugging Ember Data's behavior around JSON API payloads like this is often frustrating and non obvious. Perhaps Ember Data could do a better job of validating the JSON API payload before pushing it into the store to flag contradictions like this.
I'm currently trying to load quite a few records and their related records in one request. Sometimes Ember Data seems to fetch related records even though they were included in the request. Another weird thing is, that switching to a different model it seems like reloaded models change or unset their relations.
I've made a little twiddle for reproduction:
https://ember-twiddle.com/bbeb5040ebe8e342ecf854199e1bb0a6
Visiting this link, you'll see a list of
Playlists
, clicking one of those fetches one of those playlists with all their related data in one request (using mirage). On the first visit, it seems to make unnecessary requests to already included records ofPlaylistTrack
.Switching between Playlists also seem to have some weird behavior, where
Track
relations toArtist
seem to unset them on subsequent requests.The text was updated successfully, but these errors were encountered: