apollographql / apollo-client-nextjs

Apollo Client support for the Next.js App Router
https://www.npmjs.com/package/@apollo/experimental-nextjs-app-support
MIT License
358 stars 25 forks source link

useSuspenseQuery erroring out with get SuspenceCache #162

Closed clyncha closed 4 months ago

clyncha commented 4 months ago

Code in the getSuspenceCache is attempting to access defaultOptions.react but defaultOptions is undefined.

Screenshot 2024-01-05 at 3 41 18 PM

https://github.com/apollographql/apollo-client-nextjs/assets/89420677/da9a85c9-53cb-4755-9736-82c728358acb

I am seeing a similar issue when I swap out useSuspenseQuery for useQuery. It seems to be having an issue reading watchQuery

Screenshot 2024-01-05 at 3 57 31 PM
jerelmiller commented 4 months ago

Hey @clyncha 👋

Sorry to hear you're experiencing this! Would you be able to provide both the @apollo/client and @apollo/experimental-nextjs-app-support versions you're using?

jerelmiller commented 4 months ago

@clyncha ah wait, I noticed in your video that your client is a Promise<NextSSRApolloClient>, which is likely the cause. This should be NextSSRApolloClient itself. How are you setting up your client in your code?

clyncha commented 4 months ago

Here is how I am setting up my client

Screenshot 2024-01-05 at 4 09 10 PM

Thank you for responding so promptly :)

clyncha commented 4 months ago

Here is where I am using it instead of a client component

Screenshot 2024-01-05 at 4 09 59 PM
jerelmiller commented 4 months ago

@clyncha can you remove that async keyword on your makeClient function? That should make the error go away. Doesn't look like you need it anyways 🙂

clyncha commented 4 months ago

@clyncha can you remove that async keyword on your makeClient function? That should make the error go away. Doesn't look like you need it anyways 🙂

Oh wow I feel silly now.. that worked! Thank you

jerelmiller commented 4 months ago

You're welcome! Sometimes it helps to have an extra pair of eyes 😆. Glad to hear it worked! I'll go ahead and close this issue. Feel free to reach out if you need additional help!