commonMain.com.apollographql.apollo.interceptor.ApolloRequestInterceptor.kt Maven / Gradle / Ivy
package com.apollographql.apollo.interceptor
import com.apollographql.apollo.api.ApolloExperimental
import com.apollographql.apollo.api.Operation
import kotlinx.coroutines.flow.Flow
@ApolloExperimental
interface ApolloInterceptorChain {
fun proceed(request: ApolloRequest): Flow>
fun canProceed(): Boolean
}
@ApolloExperimental
interface ApolloRequestInterceptor {
fun intercept(request: ApolloRequest, chain: ApolloInterceptorChain): Flow>
}
@ApolloExperimental
internal class RealInterceptorChain private constructor(
private val interceptors: List,
private val index: Int
) : ApolloInterceptorChain {
constructor(interceptors: List) : this(
interceptors = interceptors,
index = 0
)
override fun proceed(request: ApolloRequest): Flow> {
check(index < interceptors.size)
return interceptors[index].intercept(request, RealInterceptorChain(interceptors = interceptors, index = index + 1))
}
override fun canProceed(): Boolean = index < interceptors.size
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy