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
393 stars 30 forks source link

`useSuspenseQuery` with `errorPolicy: 'all'` #52

Open i-tengfei opened 1 year ago

i-tengfei commented 1 year ago

When I use useSuspenseQuery with errorPolicy: 'all', rendering errors occur. The server receives the error, but on the client, the error is undefined.

phryneas commented 1 year ago

Could you maybe create a reproduction for that? Also, just to make sure: you are on version 0.3.2? There have been some changes in the 0.3 series that would fix a problem like this.

i-tengfei commented 1 year ago

https://codesandbox.io/p/sandbox/elated-smoke-m9gvk8?file=%2Fapp%2Fpage.tsx%3A19%2C26

phryneas commented 1 year ago

Yeah, this is a conceptual problem. Because the error is a non-serializable class instance, we cannot transport that one from server to browser and you get a mismatch. This would lead to a hydration mismatch, and to a client-side rerender - but we also transport the query result to the client. Again, errors cannot be transported, so the query on the client deduplicates to the "error-less version".

I'll have to see that we transport the info that there is an error to the client and retry the query on the client in that case.

artpopov commented 8 months ago

I'm having the same problem. Any updates or work-arounds for this ?