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.6k stars 448 forks source link

fix(graphcache): Record dependencies for __typename accesses #3335

Closed kitten closed 1 year ago

kitten commented 1 year ago

Summary

This changes the expected behaviour for when dependencies are recorded for caches accesses.

Note: Dependencies are basically entity or field keys marking a cache read or write. When a cache write updates a dependency, then all cache reads (i.e. queries) that have the same cache dependency will be updated accordingly, i.e. re-queried. This is how Graphcache issues updates to queries after cache writes.

While this wasn't a bug, any usage of cache.resolve(entity, '__typename') wouldn't actually record a dependency, which could cause confusion. The exception has now been removed.

Set of changes