-
Notifications
You must be signed in to change notification settings - Fork 696
Open
Labels
Description
Use case
I want to write a interceptor to log when a cache miss occurs. I only want to log it when the FetchPolicy is CacheOnly. If a request is CacheOnly and the outcome is a miss implies something is wrong on my end so I want to log those cases whilst ignoring other policies like CacheFirst where it is expected to be missed.
class MyApolloCacheMissLoggingInterceptor: ApolloInterceptor {
override fun <D : Operation.Data> intercept(request: ApolloRequest<D>, chain: ApolloInterceptorChain): Flow<ApolloResponse<D>> {
return chain.proceed(request).onEach {
//TODO add check if fetch policy is CacheOnly
if (it.exception is CacheMissException) {
Timber.e(it.exception, "Apollo cache miss on ${request.operation.name()}")
}
}
}
}
Describe the solution you'd like
I can access the executionContext in the request but FetchPolicyContext is marked as internal so I can't access it. Could this be made public ?
Reactions are currently unavailable