agrosner
09/12/2022, 1:30 PMfieldPolicy
and a typePolicy
correct. one missing piece is that it seems to use the index from the response as my caching key. somepage.somepageCardsConnection.cards.3
as an example. The id
I wish to use will reside in a nested field.
contentBlockInfo {
id
}
is my best bet to use programmatic caching ids?agrosner
09/12/2022, 1:31 PMagrosner
09/12/2022, 1:35 PMobject MonolithCacheKeyGenerator : CacheKeyGenerator {
override fun cacheKeyForObject(obj: Map<String, Any?>, context: CacheKeyGeneratorContext): CacheKey? {
if (obj["__typename"] === "SomepageCard") {
@Suppress("UNCHECKED_CAST")
return ((obj["contentBlockInfo"] as Map<String, Any?>?)?.get("id") as? String)?.let { CacheKey(it) }
?: TypePolicyCacheKeyGenerator.cacheKeyForObject(
obj,
context
)
}
return TypePolicyCacheKeyGenerator.cacheKeyForObject(obj, context)
}
}
bod
09/12/2022, 2:02 PM@typePolicy(keyFields: "id")
on SomepageCard
?bod
09/12/2022, 2:04 PMbod
09/12/2022, 2:04 PMagrosner
09/12/2022, 2:44 PM