Skip to content

Commit

Permalink
Documentation updates. (#5469) (#5473)
Browse files Browse the repository at this point in the history
Co-authored-by: Arjan Mundy <[email protected]>
  • Loading branch information
martinbonnin and ArjanSM authored Dec 13, 2023
1 parent b1d588b commit 96178f3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/source/caching/programmatic-ids.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ val cacheKeyGenerator = object : CacheKeyGenerator {
You can also use the current object's typename to use _different_ cache ID generation logic for different object types.

Note that for cache ID generation to work, your GraphQL operations must return whatever fields your custom code relies on (such as `id` above). If a query does not return a required field, the cache ID will be inconsistent, resulting in data duplication.
Also, using `context.field.type.leafType().name` yields the typename of the Union as opposed to the expected runtime value of Union received in the response. Instead querying for the `__typename` is safer.
To make sure `__typename` is included in all operations set the `adTypename` gradle config:
```
apollo {
addTypename.set("always")
//
}
```

## `CacheKeyResolver`

Expand Down

0 comments on commit 96178f3

Please sign in to comment.