You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently using next-urql for a project that generates all static paths at build time, so we're using the HOC with no exchange declarations, and ssrCache gets plugged into the wrapped component as it should.
In the server urql client, we are using some custom exchanges for auth and for deciding which endpoint to hit depending on the main selector node we use for a query, as we need to fetch from two graphql servers.
We have decided to fetch extra paginated content dynamically, and for this, I've wrapped useQuery in a new useClientQuery hook that uses some of the rules from those custom exchanges by setting up a context.
This works fine, but I wonder if it would be best, architecture-wise, to be able to declare the same custom exchanges from the server client in the client initiated with withUrqlClient and still get the auto ssrCache hookup. Right now, at least up until 5.0.2, we can't pass any exchanges to the client config in withUrqlClient if we want to have the stored state object rightly available in the first client component render.
Since exchanges is an array and the order of the exchanges matter, I wonder if this is the only caveat for allowing custom exchanges and still being able to use the same ssrCache populated on the server side - next-urql wouldn't be able to assert, in a direct manner, where in the array the codebase using it wants the server ssrCache to go.
I've noticed from other colleagues working with me on this project that it's not clear to them at first what the withUrqlClient declaration with no exchanges is doing and why setting up customs exchanges there would "break" static page optimization.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm currently using
next-urql
for a project that generates all static paths at build time, so we're using the HOC with no exchange declarations, and ssrCache gets plugged into the wrapped component as it should.In the server
urql
client, we are using some custom exchanges for auth and for deciding which endpoint to hit depending on the main selector node we use for a query, as we need to fetch from two graphql servers.We have decided to fetch extra paginated content dynamically, and for this, I've wrapped
useQuery
in a newuseClientQuery
hook that uses some of the rules from those custom exchanges by setting up acontext
.This works fine, but I wonder if it would be best, architecture-wise, to be able to declare the same custom exchanges from the server client in the client initiated with
withUrqlClient
and still get the auto ssrCache hookup. Right now, at least up until5.0.2
, we can't pass any exchanges to the client config inwithUrqlClient
if we want to have the stored state object rightly available in the first client component render.Since
exchanges
is an array and the order of the exchanges matter, I wonder if this is the only caveat for allowing custom exchanges and still being able to use the same ssrCache populated on the server side -next-urql
wouldn't be able to assert, in a direct manner, where in the array the codebase using it wants the server ssrCache to go.I've noticed from other colleagues working with me on this project that it's not clear to them at first what the
withUrqlClient
declaration with no exchanges is doing and why setting up customs exchanges there would "break" static page optimization.Thanks for the amazing work on this,
Fabio.
Beta Was this translation helpful? Give feedback.
All reactions