From db57ad3b301503cf12ea1a4ce5c28d39c8edc534 Mon Sep 17 00:00:00 2001 From: Ben Goerdt Date: Tue, 24 Mar 2020 04:11:24 -0500 Subject: [PATCH] Fix assignment of props in WithApollo.getInitialProps (#11236) The props are being assigned incorrectly based on the `inAppContext`, they should be wrapped in `pageProps` when `inAppContext` is true, not the other way around. This will cause a new apollo client to be created during `getDataFromTree` instead of using the one that has already been created on the server. --- examples/with-apollo/lib/apollo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/with-apollo/lib/apollo.js b/examples/with-apollo/lib/apollo.js index bff375c2cf927..15a7a6202772e 100644 --- a/examples/with-apollo/lib/apollo.js +++ b/examples/with-apollo/lib/apollo.js @@ -137,9 +137,9 @@ export const withApollo = ({ ssr = false } = {}) => PageComponent => { // we need to modify their props a little. let props if (inAppContext) { - props = { ...pageProps, apolloClient } - } else { props = { pageProps: { ...pageProps, apolloClient } } + } else { + props = { ...pageProps, apolloClient } } // Take the Next.js AppTree, determine which queries are needed to render,