All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.apollographql.cache.normalized.CacheMissLoggingInterceptor.kt Maven / Gradle / Ivy

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())
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy