v12.1.5 regression with apollo client in SSR
See original GitHub issueVerify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64
Binaries:
Node: 14.19.1
npm: 6.14.16
Yarn: 1.22.17
pnpm: N/A
Relevant packages:
next: 12.1.5
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
we use the classic approach of doing ssr with @apollo/client where it runs getDataFromTree on the server and hydrates the client in a getInitialProps function.
when I upgraded next from 12.1.4 to 12.1.5 this broke:
Error while running `getDataFromTree` Invariant Violation: Could not find "client" in the context or passed in as an option. Wrap the root component in an <ApolloProvider>, or pass an ApolloClient instance in via options.
at new InvariantError (/path/project/node_modules/@apollo/client/node_modules/ts-invariant/lib/invariant.esm.js:12:28)
at Object.invariant (/path/project/node_modules/@apollo/client/node_modules/ts-invariant/lib/invariant.esm.js:24:15)
at useApolloClient (/path/project/node_modules/@apollo/client/react/hooks/useApolloClient.js:7:15)
at useQuery (/path/project/node_modules/@apollo/client/react/hooks/useQuery.js:13:18)
at useAssortment (webpack-internal:///./src/modules/categories/hooks/useAssortment.ts:31:97)
at CategoryPage (webpack-internal:///./src/modules/categories/components/ShopRegularCategory.tsx:56:122)
at processChild (/path/project/node_modules/react-dom/cjs/react-dom-server.node.development.js:3353:14)
at resolve (/path/project/node_modules/react-dom/cjs/react-dom-server.node.development.js:3270:5)
at ReactDOMServerRenderer.render (/path/project/node_modules/react-dom/cjs/react-dom-server.node.development.js:3753:22)
at ReactDOMServerRenderer.read (/path/project/node_modules/react-dom/cjs/react-dom-server.node.development.js:3690:29) {
framesToPop: 1
}
Expected Behavior
this kind of setup should not be affected by a patch-release
To Reproduce
will try to provide later, i still need to gather information and try to find out which actual change is the root cause o this bug.
Issue Analytics
- State:
- Created a year ago
- Reactions:10
- Comments:17 (7 by maintainers)
Top Results From Across the Web
Server-side rendering - Apollo GraphQL Docs
Server-side rendering (SSR) is a performance optimization for modern web apps. It enables you to render your app's initial state to raw HTML...
Read more >Getting Started With Apollo Client in Next.js
In this post, we'll briefly cover each way to fetch and render data with Next.js, along with the important considerations for each approach....
Read more >Server-side rendering - Apollo GraphQL Docs
These functions take care of the job of fetching all queries that are required to rendering your component tree. Typically you would use...
Read more >Building a Next.js App with Apollo Client & Slash GraphQL
initialState }); } // For SSG and SSR always create a new Apollo Client ... fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 ...
Read more >SSR - Apollo GraphQL Docs
SSR. Apollo Client React server side rendering API. Installation. Apollo Client >= 3 includes React hooks functionality out of the box.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not sure if I can provide one in the next few hours or days. One important thing to know is, that its not about react 18. Its happening with react 17.
conceptually my case is very similar to the one @KATT provided with his
TRPC
example. There theApp
component inpages/_app
is wrapped in a HOCwithTRPC
which provides the right context and collects data on SSR to hydrate the client cache. My guess is that there might be a problem how the App-component of_app
is mountedConfirmed fixed in https://github.com/KATT/next.js-issues-36115/pull/4