data icon indicating copy to clipboard operation
data copied to clipboard

Investigate potentially unnecessary relationship refetch

Open runspired opened this issue 7 years ago • 2 comments

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`.
}

runspired avatar Apr 19 '18 06:04 runspired

I think I may be running into the same thing.

https://ember-twiddle.com/840a1b37e2409723bfb8373690f58359

HeroicEric avatar Aug 02 '18 15:08 HeroicEric

#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.

runspired avatar Aug 09 '18 00:08 runspired

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

runspired avatar Nov 17 '22 02:11 runspired