commonMain.com.apollographql.cache.normalized.CacheMissLoggingInterceptor.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of normalized-cache-incubating-jvm Show documentation
Show all versions of normalized-cache-incubating-jvm Show documentation
Apollo Kotlin Incubating Normalized Cache
The newest version!
package com.apollographql.cache.normalized
import com.apollographql.apollo.api.ApolloRequest
import com.apollographql.apollo.api.ApolloResponse
import com.apollographql.apollo.api.Operation
import com.apollographql.apollo.exception.CacheMissException
import com.apollographql.apollo.interceptor.ApolloInterceptor
import com.apollographql.apollo.interceptor.ApolloInterceptorChain
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.onEach
class CacheMissLoggingInterceptor(private val log: (String) -> Unit) : ApolloInterceptor {
override fun intercept(request: ApolloRequest, chain: ApolloInterceptorChain): Flow> {
return chain.proceed(request).onEach {
if (it.exception is CacheMissException) {
log(it.exception!!.message.toString())
}
}
}
}