Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.

Add updater docs for #3843 (#3851)

authored by

Jovi De Croock and committed by
GitHub
71f049c6 3396ba70

+17
+5
docs/api/graphcache.md
··· 106 106 to update data in the cache that is implicitly changed on the GraphQL API, that _Graphcache_ can't 107 107 know about automatically. 108 108 109 + For mutation fields that don't have an updater, Graphcache has a fallback: if a returned entity 110 + isn't currently found in the cache, it assumes a create-mutation and invalidates cached 111 + entities of that type. This behavior was introduced in Graphcache v7 and is skipped once an updater 112 + for the mutation field is added. 113 + 109 114 ```ts 110 115 interface UpdatesConfig { 111 116 Mutation: {
+12
docs/graphcache/cache-updates.md
··· 59 59 }); 60 60 ``` 61 61 62 + ## Default mutation invalidation 63 + 64 + Starting in [Graphcache v7](https://github.com/urql-graphql/urql/blob/main/exchanges/graphcache/CHANGELOG.md#700), 65 + mutations without a configured `updates.Mutation.<fieldName>` updater have a fallback behavior: 66 + 67 + - If the mutation returns an entity that can't be found in the cache yet, Graphcache treats this as 68 + a "create" mutation. 69 + - Graphcache then invalidates cached entities of the same `__typename` as the one returned from the mutation, which can trigger related queries to refetch. 70 + 71 + As soon as you define an updater for that mutation field, this fallback behavior no longer runs and 72 + your updater fully controls what happens after the mutation write. 73 + 62 74 An "updater" may be attached to a `Mutation` or `Subscription` field and accepts four positional 63 75 arguments, which are the same as [the resolvers' arguments](./local-resolvers.md): 64 76