-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled Runtime Error getClient)(...).query is not a function when upgrading from Next.js 14.1.0 to 14.1.1 #336
Comments
Hi Jens, thank you for the report! I just tried bumping Could you please try to create a reproduction? |
Hi Lenz. Thanks for getting back to me so quickly. I've packaged up what I think is the bare minimum required to reproduce the issue and have attached it here: Run |
I see it now. Irritatingly, doing const registeredClient = registerApolloClient(() => {
return new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
uri: "https://graphqlzero.almansi.me/api",
}),
});
});
export const { getClient, query, PreloadQuery } = registeredClient; which just saves it to a variable first and should be absolutely equivalent doesn't fail for me. I believe you found a bug in Next.js here - could you open an issue with them and link back to this issue so I can follow along please? |
PS: unrelated - but maybe useful: As a neat trick, you can just use the exported -import { getClient } from "@/apollo/ApolloRSC";
+import { query } from "@/apollo/ApolloRSC";
const DashboardHome = async () => {
- const { data } = await getClient().query({ query: testQuery });
+ const { data } = await query({ query: testQuery }); |
Thanks for the workaround and suggestions Lenz - much appreciated. I've filed a bug with next: vercel/next.js#68413 |
I'm migrating a Next.js app from the pages to the app router. I'm currently using:
"@apollo/client": "3.11.1"
"@apollo/experimental-nextjs-app-support": "0.11.2"
"next": "14.1.1"
I've followed the recommendations in the README and am using the following code to set up the Apollo Client:
I call the client like this:
const { data } = await getClient().query({ query: getUserQuery });
With Next.js 14.1.0, this works fine. If I upgrade to Next.js 14.1.1, I get the following error:
The text was updated successfully, but these errors were encountered: