Open linucks opened 1 month ago
Hi Jens, thank you for the report!
I just tried bumping next
to 14.1.1
in our integration tests over in #337, but I cannot see the problem happening there.
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 yarn install && yarn dev
and then go to http://localhost:3000/dashboard to see the error.
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 query
instead of getClient().query
- it's a shortcut :)
-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: https://github.com/vercel/next.js/issues/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: