Prefetching & SSR Cache Hydration
Even with automatic query batching, deeply nested UI trees can trigger sequential request waterfalls if child components only mount after parent data resolves. GQless provides prefetch() and hydrateCache() to populate the cache ahead of render.
// Warm the cache on link hover or route loader
await prefetch((query) => {
const post = query.post({ slug: 'proxy-architecture' });
return [post?.title, post?.publishedAt, post?.author?.name];
});
// Hydrate serialized SSR cache on the client
hydrateCache({ cacheSnapshot: window.__GQLESS_CACHE__ });
Zero duplicate fetches: Once hydrated, components reading the same fields resolve synchronously from the normalized cache without issuing another network round-trip.
Pair SSR prefetching with modern web rendering strategies and tune staleWhileRevalidate in ClientOptions. See also Proxy-Based Query Generation.