Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(graphcache): Mutable links on InMemoryData store (#3516)

authored by

Phil Pluckthun and committed by
GitHub
969935c6 56c1544b

+10 -5
+5
.changeset/wicked-kids-joke.md
··· 1 + --- 2 + '@urql/exchange-graphcache': patch 3 + --- 4 + 5 + Fix `store.resolve()` returning the exact link array that’s used by the cache. This can lead to subtle bugs when a user mutates the result returned by `cache.resolve()`, since this directly mutates what’s in the cache at that layer.
+5 -5
exchanges/graphcache/src/store/store.ts
··· 153 153 field: string, 154 154 args?: FieldArgs 155 155 ): DataField | undefined { 156 - let fieldValue: DataField | undefined = null; 157 156 const entityKey = this.keyOfEntity(entity); 158 157 if (entityKey) { 159 158 const fieldKey = keyOfField(field, args); 160 - fieldValue = InMemoryData.readRecord(entityKey, fieldKey); 161 - if (fieldValue === undefined) 162 - fieldValue = InMemoryData.readLink(entityKey, fieldKey); 159 + const fieldValue = InMemoryData.readRecord(entityKey, fieldKey); 160 + if (fieldValue !== undefined) return fieldValue; 161 + let fieldLink = InMemoryData.readLink(entityKey, fieldKey); 162 + if (fieldLink !== undefined) fieldLink = ensureLink(this, fieldLink); 163 + return fieldLink; 163 164 } 164 - return fieldValue; 165 165 } 166 166 167 167 resolveFieldByKey(entity: Entity, field: string, args?: FieldArgs) {