Open dameradev opened 5 days ago
I just commented in the forum, but let's continue the conversation here:
We cannot stream queries from the server to the client that contain only client-local fields.
Also keep in mind that makeVar
has the risk here to share data between all your users during SSR. It's like a global variable.
I just commented in the forum, but let's continue the conversation here:
We cannot stream queries from the server to the client that contain only client-local fields.
Also keep in mind that
makeVar
has the risk here to share data between all your users during SSR. It's like a global variable.
So what's the solution here?
How can I make sure to stream these queries only on the client?
I'm afraid, you probably won't be able to use makeVar
, just like any other global state solution, with a SSR approach like Next.js at all.
Even if we could solve the "data of multiple users is getting mixed up" problem, every future render on the server would not know what data the user has set in the browser, so it would render "initial data" again.
If you can ensure that all of this will only be accessed in the browser (keep in mind that Next.js SSRs your Client Component, too!), I would recommend skipping Apollo Client here and calling useReactiveVar
instead of useQuery
/useSuspenseQuery
.
That said, this is a very strong if. You probably would have to avoid rendering whole subtrees of your app on the server, with something like
const isOnServer = useSyncExternalStore(() => {}, () => false, () => true)
and then conditionally rendering children or not.
Hello, we recently updated to "@apollo/experimental-nextjs-app-support"; We need this to run server queries.
The problem is that now our global store queries are throwing the error below when on first page visit/refresh.
Versions
This is the error we're getting
Below is how we've setup the apollo wrapper
Here's the query that's erroring out (one of them, all global store queries are erroring out)
Here's how it's all defined