Regression in Next.js 14.1.1 breaks Apollo Client functionality.
The issue involves a regression in Next.js 14.1.1 that breaks Apollo Client functionality, specifically affecting destructured method calls. The problem is reproducible and has been confirmed by multiple users. The fix likely requires understanding both Next.js and Apollo Client internals.
https://github.com/linucks/nextjs-apollo-bug
npm install && npm run devThe code should perform a query using Apollo GraphQL and display the returned data. Instead it fails with:
⨯ app/page.tsx (15:36) @ query
⨯ TypeError: (0 , _apollo_ApolloRSC__WEBPACK_IMPORTED_MODULE_1__.getClient)(...).query is not a function
at eval (webpack-internal:///(rsc)/./app/page.tsx:22:87)
at __webpack_require__.a (/opt/nextjs-apollo-bug/.next/server/webpack-runtime.js:105:13)
at eval (webpack-internal:///(rsc)/./app/page.tsx:1:21)
at (rsc)/./app/page.tsx (/opt/nextjs-apollo-bug/.next/server/app/page.js:194:1)
at Function.__webpack_require__ (/opt/nextjs-apollo-bug/.next/server/webpack-runtime.js:33:42)
at async e7 (/opt/nextjs-apollo-bug/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:396786)
at async rU (/opt/nextjs-apollo-bug/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:39:7290)
at async /opt/nextjs-apollo-bug/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:39:10360
at async Promise.all (index 0)
at async rU (/opt/nextjs-apollo-bug/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:39:10036)
at async r1 (/opt/nextjs-apollo-bug/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:39:17308) {
digest: '2448613812',
page: '/'
}
13 | `;
14 |
> 15 | const { data } = await getClient().query({ query: testQuery });
| ^
16 |
17 | export default function Home() {
18 | return (
GET / 500 in 167ms
Reverting to version 14.1.0 resolves the issue. All NextJS releases tested after 14.1.1 display the problem.
I originally [reported the issue](https://github.com/apollograph
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!