You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to get this package to work with an existing application that we're trying to upgrade to Next.js 12. Our application was built using getDataFromTree and refactoring everything to use the new getServerSideProps approach is going to be an enormous lift for us.
I've followed along with the example here https://github.com/lfades/next-with-apollo#using-_app as best I can but initialState is coming up as undefined inside the withApollo() function. I am passing getDataFromTree from @apollo/client/react/ssr:
export default withApollo (({initialState}) => {
// App-specific authentication logic, setting up authMiddleware using ApolloLink and HttpLink
return new ApolloClient({
cache: new InMemoryCache({
dataIdFromObject: object => object.sku || object.id
}).restore(initialState || {}),
link: concat(authMiddleware, httpLink)
}),
},
{ getDataFromTree})(AppWithRedux)
A couple of additional factors:
The existing AppWithRedux is a class component with a getInitialProps static method (I am calling App.getInitialProps like the Next.js docs show, that seems to be working).
We (obviously) have a custom _app. We also have a custom _document, I'm wondering if we need to do anything additional due to using a custom document? We might be facing the same issue as this user because we use Styled Components so there is a bunch of stylesheet and other third-party code setup in there.
Any help would be appreciated, thank you!
The text was updated successfully, but these errors were encountered:
Hello,
I'm trying to get this package to work with an existing application that we're trying to upgrade to Next.js 12. Our application was built using
getDataFromTree
and refactoring everything to use the newgetServerSideProps
approach is going to be an enormous lift for us.I've followed along with the example here https://github.com/lfades/next-with-apollo#using-_app as best I can but
initialState
is coming up asundefined
inside thewithApollo()
function. I am passinggetDataFromTree
from@apollo/client/react/ssr
:A couple of additional factors:
AppWithRedux
is a class component with agetInitialProps
static method (I am callingApp.getInitialProps
like the Next.js docs show, that seems to be working).Any help would be appreciated, thank you!
The text was updated successfully, but these errors were encountered: