Skip to content

Commit

Permalink
Only restore uncached operation data into ssr-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zachasme committed Jul 6, 2021
1 parent 891a17a commit 08e7c06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion exchanges/graphcache/default-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"./package.json": "./package.json"
},
"dependencies": {
"@urql/core": ">=2.0.0",
"@urql/core": ">=2.1.4",
"wonka": "^4.0.14"
}
}
11 changes: 10 additions & 1 deletion packages/core/src/exchanges/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,16 @@ export const ssrExchange = (params?: SSRExchangeParams): SSRExchange => {
return merge([forwardedOps$, cachedOps$]);
};

ssr.restoreData = (restore: SSRData) => Object.assign(data, restore);
ssr.restoreData = (restore: SSRData) => {
// Only restore data for uncached operations
const uncached = {};
Object.entries(restore).forEach(([key, value]) => {
if (false === key in data) {
uncached[key] = value;
}
});
return Object.assign(data, uncached);
};
ssr.extractData = () => Object.assign({}, data);

if (params && params.initialState) {
Expand Down

0 comments on commit 08e7c06

Please sign in to comment.