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

(next) - allow subsequent statically generated pages to hydrate the ssr-cache (#1602)

* allow subsequent statically generated pages to hydrate the ssr-cache

* remove testing code

Changed files
+8
.changeset
examples
with-next
packages
next-urql
+5
.changeset/witty-spiders-matter.md
···
+
---
+
'next-urql': minor
+
---
+
+
Allow subsequent static-pages to hydrate the cache
+1
examples/with-next/package.json
···
"urql": "^2.0.2"
},
"scripts": {
+
"dev": "next dev",
"start": "next",
"build": "next build"
}
+2
packages/next-urql/src/with-urql-client.ts
···
if (!ssr || typeof window === 'undefined') {
// We want to force the cache to hydrate, we do this by setting the isClient flag to true
ssr = ssrExchange({ initialState: urqlServerState, isClient: true });
+
} else if (ssr && typeof window !== 'undefined') {
+
ssr.restoreData(urqlServerState);
}
const clientConfig = getClientConfig(ssr);