diff --git a/api/ssrApollo.js b/api/ssrApollo.js index 1341f47d..26aa5d94 100644 --- a/api/ssrApollo.js +++ b/api/ssrApollo.js @@ -38,14 +38,14 @@ export default async function getSSRApolloClient ({ req, res, me = null }) { assumeImmutableResults: true, defaultOptions: { watchQuery: { - fetchPolicy: 'cache-only', - nextFetchPolicy: 'cache-only', + fetchPolicy: 'no-cache', + nextFetchPolicy: 'no-cache', canonizeResults: true, ssr: true }, query: { - fetchPolicy: 'cache-first', - nextFetchPolicy: 'cache-only', + fetchPolicy: 'no-cache', + nextFetchPolicy: 'no-cache', canonizeResults: true, ssr: true } diff --git a/lib/apollo.js b/lib/apollo.js index 83f36b12..7f0ed314 100644 --- a/lib/apollo.js +++ b/lib/apollo.js @@ -150,13 +150,15 @@ function getClient (uri) { initialFetchPolicy: defaultFetchPolicy, fetchPolicy: defaultFetchPolicy, nextFetchPolicy: defaultNextFetchPolicy, - canonizeResults: true + canonizeResults: true, + ssr: SSR }, query: { initialFetchPolicy: defaultFetchPolicy, fetchPolicy: defaultFetchPolicy, nextFetchPolicy: defaultNextFetchPolicy, - canonizeResults: true + canonizeResults: true, + ssr: SSR } } }) diff --git a/pages/_app.js b/pages/_app.js index b29475d9..829b3bb5 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -72,10 +72,6 @@ function MyApp ({ Component, pageProps: { ...props } }) { ssr data */ const { apollo, ssrData, me, price, ...otherProps } = props - // if we are on the server, useEffect won't run - if (SSR && client) { - writeQuery(client, apollo, ssrData) - } useEffect(() => { writeQuery(client, apollo, ssrData) }, [client, apollo, ssrData])