diff --git a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo/ApolloClient.kt b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo/ApolloClient.kt index 3158e64df7b..4c52421017f 100644 --- a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo/ApolloClient.kt +++ b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo/ApolloClient.kt @@ -220,6 +220,11 @@ private constructor( concurrencyInfo.coroutineScope.cancel() networkTransport.dispose() subscriptionNetworkTransport.dispose() + for (interceptor in interceptors) { + if (interceptor is Closeable) { + interceptor.close() + } + } } private val networkInterceptor = NetworkInterceptor( diff --git a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloInterceptor.kt b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloInterceptor.kt index fc77d9e3740..65669486bce 100644 --- a/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloInterceptor.kt +++ b/libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloInterceptor.kt @@ -1,14 +1,18 @@ package com.apollographql.apollo.interceptor import com.apollographql.apollo.api.ApolloRequest -import com.apollographql.apollo.api.Operation import com.apollographql.apollo.api.ApolloResponse +import com.apollographql.apollo.api.Operation import kotlinx.coroutines.flow.Flow interface ApolloInterceptorChain { fun proceed(request: ApolloRequest): Flow> } +/** + * Implementations can optionally implement [okio.Closeable], if they do, their [okio.Closeable.close] function will be called when the + * [com.apollographql.apollo.ApolloClient] they are associated to is closed. + */ interface ApolloInterceptor { fun intercept(request: ApolloRequest, chain: ApolloInterceptorChain): Flow> }