@@ -4,11 +4,11 @@ import com.apollographql.apollo.api.ApolloRequest
4
4
import com.apollographql.apollo.api.ApolloResponse
5
5
import com.apollographql.apollo.api.MutableExecutionOptions
6
6
import com.apollographql.apollo.api.Operation
7
- import com.apollographql.apollo.exception.ApolloException
8
7
import com.apollographql.apollo.interceptor.ApolloInterceptor
9
8
import com.apollographql.apollo.interceptor.ApolloInterceptorChain
10
9
import com.apollographql.cache.normalized.FetchPolicy
11
10
import com.apollographql.cache.normalized.cacheInfo
11
+ import com.apollographql.cache.normalized.errorsAsException
12
12
import com.apollographql.cache.normalized.fetchFromCache
13
13
import com.apollographql.cache.normalized.fetchPolicy
14
14
import com.apollographql.cache.normalized.fetchPolicyInterceptor
@@ -53,29 +53,11 @@ private object CacheFirstInterceptor : ApolloInterceptor {
53
53
if (networkResponse.exception == null || ! first) {
54
54
networkResponse
55
55
} else {
56
- cacheResponse.cacheMissAsException ()
56
+ cacheResponse.errorsAsException ()
57
57
}
58
58
)
59
59
first = false
60
60
}
61
61
}
62
62
}
63
63
}
64
-
65
- private fun <D : Operation .Data > ApolloResponse<D>.cacheMissAsException (): ApolloResponse <D > {
66
- return if (cacheInfo!! .isCacheHit) {
67
- this
68
- } else {
69
- val cacheMissException =
70
- errors.orEmpty().mapNotNull { it.extensions?.get(" exception" ) as ? ApolloException }.reduceOrNull { acc, e ->
71
- acc.addSuppressed(e)
72
- acc
73
- }
74
- newBuilder()
75
- .exception(cacheMissException)
76
- .data(null )
77
- .errors(null )
78
- .build()
79
- }
80
- }
81
-
0 commit comments