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): fix restoring variables on mutation operations (#3046)

authored by

Jovi De Croock and committed by
GitHub
d41fac83 c8b0623d

+11 -1
+5
.changeset/fifty-jeans-invite.md
··· 1 + --- 2 + '@urql/exchange-graphcache': patch 3 + --- 4 + 5 + Restore variables correctly on mutations
+6 -1
exchanges/graphcache/src/cacheExchange.ts
··· 153 153 ) 154 154 : operation.variables, 155 155 }, 156 - operation.context 156 + { ...operation.context, originalVariables: operation.variables } 157 157 ); 158 158 }; 159 159 ··· 208 208 : result.operation; 209 209 210 210 if (operation.kind === 'mutation') { 211 + if (result.operation.context.originalVariables) { 212 + operation.variables = result.operation.context.originalVariables; 213 + delete result.operation.context.originalVariables; 214 + } 215 + 211 216 // Collect previous dependencies that have been written for optimistic updates 212 217 const dependencies = optimisticKeysToDependencies.get(operation.key); 213 218 collectPendingOperations(pendingOperations, dependencies);