From 53834c6f3c109d58ced4c47922661c7a99b514eb 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 766dd8ee8949794..58cdf83d1b7e3d5 100644 --- a/examples/with-apollo/lib/apollo.js +++ b/examples/with-apollo/lib/apollo.js @@ -40,6 +40,15 @@ export function withApollo(PageComponent, { ssr = true } = {}) { 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.') }