read cache on from server #1193
-
Hi, I'm using @urql/core ssr and I want to retrieve information from the server side cache. I can extractData, expose it in the window object, retrieve it on the client etc. but I don't know how to read the data from the server in order to extract a data to put it in the title tags before sending it back to the frontend. In fact, I can see the cache but it has a number on it that I can't guess. Is there a method to read the current cache from the server? I hope I made myself clear. Cdlt |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
No entirely sure what you're meaning to do, however there are a few scenario's that come to mind. In a typical server-side rendering scenario we'll use the This is an exchange we'll use both on the server and the client, when used on the server we'll call
When you use this exchange on the client this will hydrate your local-cache with everything you have fetched on the server, this means that if you call |
Beta Was this translation helpful? Give feedback.
-
Yes, thank you, I put all this logic in place. I think my logic is not good for what I want to do. My idea was to be able to retrieve in extractData the data to hydrate the server side of my Layout (the title in this case). But I think my logic is not good. I'll rather transmit the data to my Layout from where I get it using streams for sure. Thanks for the answer |
Beta Was this translation helpful? Give feedback.
No entirely sure what you're meaning to do, however there are a few scenario's that come to mind. In a typical server-side rendering scenario we'll use the
ssrExchange
.This is an exchange we'll use both on the server and the client, when used on the server we'll call
extractData
and it to a<script>
tag on the window so we get the data-shape you describe:When you use this exchange on the client this will hydrate your local-cache with everything you have fetched on the server, this means that if you call
useQuery
on the client you'll get a synchronous result (won't hit your server with thefetchExchange
) and this entry will now live in the client-sid…