-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@apollo/client": patch | ||
--- | ||
|
||
Fix a bug where other fields could be aliased to `__typename` or `id`, in which case an incoming result would be merged into the wrong cache entry. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -382,7 +382,7 @@ export class Policies { | |
const policy = typename && this.getTypePolicy(typename); | ||
let keyFn = policy && policy.keyFn || this.config.dataIdFromObject; | ||
while (keyFn) { | ||
const specifierOrId = keyFn(object, context); | ||
const specifierOrId = keyFn({...object, ...storeObject}, context); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
phryneas
Author
Member
|
||
if (isArray(specifierOrId)) { | ||
keyFn = keyFieldsFnFromSpecifier(specifierOrId); | ||
} else { | ||
|
I want to understand what exactly is happening here.
When this merge introduced our cache won't behave correctly, We have custom logic to use different id for caching.
And it seems to me that we've checked already in the beginning at line 372 whether we're going to use object or storeObject. But merging like this brings back storeObject it seems and breaks caching. Or am I wrong?