From 205014f6b103c5796c17ee3dbc9f8690a8d69c3b Mon Sep 17 00:00:00 2001 From: handtrix Date: Wed, 5 Feb 2020 14:48:52 +0100 Subject: [PATCH] Add Automatic Static Optimization warning --- examples/with-apollo/lib/apollo.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/with-apollo/lib/apollo.js b/examples/with-apollo/lib/apollo.js index c4365e6357b40cc..61721bbf2d21174 100644 --- a/examples/with-apollo/lib/apollo.js +++ b/examples/with-apollo/lib/apollo.js @@ -37,6 +37,15 @@ export const withApollo = ({ ssr = true } = {}) => PageComponent => { const { AppTree } = ctx const inAppContext = Boolean(ctx.ctx) + if (process.env.NODE_ENV === 'development') { + if (inAppContext) { + console.warn( + 'Warning: You have opted-out of Automatic Static Optimization due to `withApollo` in `pages/_app`.\n' + + 'Read more: https://err.sh/next.js/opt-out-auto-static-optimization\n' + ) + } + } + if (ctx.apolloClient) { throw new Error('Multiple instances of withApollo found.') }