SSR prefetchQuery partial key
hi
client side I have
I'd like to prefetch it server side, so I'm doing the following:
unfortunately I need to specify the exact query to prefetch it
how can I achieve this as I do not have the auth state server side?
can I specify a partial key server side?
thanks!
4 Replies
wise-white•3y ago
what's the use-case?
subsequent-cyanOP•3y ago
here's my page:
on the first load my page is correct as I get the data from the server, however my user is not auth right away as auth state is refreshed client side , then the auth is processed and the query key is updated to
['foo', true] so I dont have data anymore and my page renders null while the data is fetched.
I was thinking about switching the query key server side to a partial one:
but by this time I did not understand completely how prefetchQuery works,
now I believe I do a bit more and I imagine the issue here is more related to my logic of rendering the page
but, in the end my query key will be updated as I dont need anymore the isAuth in the key and it should fix my issue
hope I was clear!wise-white•3y ago
I guess you just want
keepPreviousData ? It doesn't make much sense to me to have the same data in the cache for both isAuth and not isAuth. If that's what you want, you could just not use isAuth for this request at all ...subsequent-cyanOP•3y ago
I even think I could have use the
keepPreviousData
yup