Getting a `CacheMissException` in StarWars sample ...
# apollo-kotlin
j
Getting a
CacheMissException
in StarWars sample (https://github.com/joreilly/StarWars) after moving to v4 (didn't notice when I updated at time as it was using cache I believe)....version in repo is
4.0.0-alpha.2
but see same issue with beta-4. It could be some migration step missing perhaps but just in case any obvious things to look out for? More in 🧵
Copy code
-13 17:18:28.994 10990 10990 E AndroidRuntime: Process: dev.johnoreilly.starwars.androidApp, PID: 10990
12-13 17:18:28.994 10990 10990 E AndroidRuntime: com.apollographql.apollo3.exception.CacheMissException: Object 'QUERY_ROOT' has no field named 'allPeople'
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.api.DefaultCacheResolver.resolveField(CacheResolver.kt:97)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.api.FieldPolicyCacheResolver.resolveField(CacheResolver.kt:188)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.api.internal.CacheBatchReader.toMap(CacheBatchReader.kt:115)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.api.OperationCacheExtensionsKt.readInternal(OperationCacheExtensions.kt:78)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.api.OperationCacheExtensionsKt.readDataFromCache(OperationCacheExtensions.kt:41)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.internal.DefaultApolloStore$readOperation$2.invoke(DefaultApolloStore.kt:103)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.internal.DefaultApolloStore$readOperation$2.invoke(DefaultApolloStore.kt:102)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.internal.Lock.read(Lock.kt:12)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.internal.DefaultApolloStore.readOperation(DefaultApolloStore.kt:102)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.internal.ApolloCacheInterceptor.readFromCache(ApolloCacheInterceptor.kt:209)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.internal.ApolloCacheInterceptor.access$readFromCache(ApolloCacheInterceptor.kt:38)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.internal.ApolloCacheInterceptor$interceptQuery$1.invokeSuspend(ApolloCacheInterceptor.kt:194)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.internal.ApolloCacheInterceptor$interceptQuery$1.invoke(Unknown Source:8)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at com.apollographql.apollo3.cache.normalized.internal.ApolloCacheInterceptor$interceptQuery$1.invoke(Unknown Source:4)
12-13 17:18:28.994 10990 10990 E AndroidRuntime: 	at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61)
key part of this seems to be
CacheMissException: Object 'QUERY_ROOT' has no field named 'allPeople'
b
but v4 shouldn't throw 🤔
j
it's quite likely I missed something in the migration
b
oh you use
dataAssertNoErrors
so it's normal that it throws in that case actually
so in v4 caches misses are emitted... so you should probably filter them out from the watch:
Copy code
apolloClient.query(query).watch().filter { it.exception == null }
j
ok, thanks, I'll try that
b
(it's this paragraph in the migration guide)
j
so I shouldn't use
dataAssertNoErrors
any more (or
dataOrThrow
which is current version of that it seems) ?
nvm, that looks unrelated.....so, with that filter it's now working, thanks!
🎉 1
b
so I shouldn't use
dataAssertNoErrors
any more
it depends, it could be useful in some cases 🙂 But the difference is that previously in v3, the cache miss would not have been emitted, so it would not have thrown.