don't use cache for SSR

This commit is contained in:
keyan 2023-08-05 14:46:29 -05:00
parent b9fdbde520
commit e4aaaac20f
3 changed files with 8 additions and 10 deletions

View File

@ -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
}

View File

@ -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
}
}
})

View File

@ -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])