Skip to content

Commit

Permalink
Preserve unchanged { __ref: <data ID> } object references.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Sep 17, 2019
1 parent 5c2bab0 commit 6500d50
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/cache/inmemory/writeToStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,11 @@ function mergeStoreObjects(
}

if (isReference(incoming)) {
// Incoming references always overwrite existing references.
if (isReference(existing)) return incoming;
if (isReference(existing)) {
// Incoming references always replace existing references, but we can
// avoid changing the object identity when the __ref is the same.
return incoming.__ref === existing.__ref ? existing : incoming;
}
// Incoming references can be merged with existing non-reference data
// if the existing data appears to be of a compatible type.
store.set(
Expand Down

0 comments on commit 6500d50

Please sign in to comment.