Investigate potentially unnecessary relationship refetch
Reported by @fivetanley here. I will need an example "fail case" payload to produce a test and debug.
scenario
const IdentityProvider = DS.Model.extend({
owner: belongsTo('identity-provider-owner', {
polymorphic: true,
inverse: 'identityProvider'
})
})
const Account = DS.Model.extend({
identityProvider: belongsTo({ inverse: 'owner' })
});
const provider = store.createRecord('identity-provider', { owner: owner });
try {
await provider.save();
} catch (e) {
provider.unloadRecord(); // causes refetch of account.get('identityProvider'), even if the canonical state is `null`.
}
I think I may be running into the same thing.
https://ember-twiddle.com/840a1b37e2409723bfb8373690f58359
#5525 is potentially a duplicate of this.
Primarily we need to add a failing test that captures the cases described above, in the linked ticket, and for one described offline (the same as above but no call to save the new record is made). From there we can determine the right fix.
closing since the related ticket was resolved that we thought was a duplicate and we don't have an example payload that was triggering the fail-scenario