-
-
Notifications
You must be signed in to change notification settings - Fork 450
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
Data constant inside ssrExchange is incorrectly initialised and used #3653
Comments
So, this doesn't check out to me, and this seems like a usage issue rather than a bug to me. All seems as intended. Since the reproduction here doesn't use the Since I'm not quite sure what your use-case / desired behaviour / problem is, let me take a step back and illustrate how we think the There's basically two modes the
The It's expected that on the client-side the instance of In other words, on the client, the
However, on the server-side it's expected that you create an As per the above, on the server, the
Hence, This is probably clearer to see in the legacy Does that make sense? I'm curious where you're diverging with this in terms of what you're trying to build. |
Thanks for your lengthy explanation. I was midway writing another lengthy reply, but it turns out that following the approach from the github repo you shared was enough. Unfortunately, our case is too complex to use Thanks again for your help. |
Alright, glad that cleared it up! I'm sorry this isn't in the docs. We've had a bit of trouble and indecision of where to go next with the docs since they've been under some conditions and are still tied to |
Describe the bug
Inside SSR exchange (
/packages/core/src/exchanges/ssr.ts
) the exposedssrExchange
is a function which initialises thedata
constant each time the exchange is created (i.e. each timessrExchange
is called). However, inside thessrExchange
function, there is the definition of the exchange itself (thessr
constant) which will always use the very original instance of thedata
constant. This means, that if I call the ssrExchange e.g. 5 times, thedata
constant will be created 5 times, but inside thessr
function, the first reference will be used.The repro stackblitz contains a minimal example together with thoroughly explained repro steps in README.md.
Reproduction
https://stackblitz.com/edit/github-is7frs?file=README.md
Urql version
"@urql/core": "^5.0.5"
"urql": "^4.1.0"
"next-urql": "^5.0.2",
Validations
The text was updated successfully, but these errors were encountered: