urql-graphql / urql

The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
https://urql.dev/goto/docs
MIT License
8.57k stars 445 forks source link

RFC: Add `onCacheHydrated` event #3422

Closed elilabes closed 8 months ago

elilabes commented 9 months ago

Summary

Add a new onCacheHydrated method to Urql. This would be called when Urqls cache has been hydrated from disk (e.g. when using the @urql/storage-rn package).

The reason we need this event is so that we can wait for the cache to be hydrated before mounting any components that use Urql. Without it, the app bootstraps very quickly, before Urql has hydrated the cache, causing each query to be awaited from the network. We use the cache-and-network policy, so we want the network to be hit, but we want to show our cached results immediately.

Additional discord context

Proposed Solution

Add an event so that we can know when Urqls cache is ready.