File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
libraries/apollo-compose-support/src/main/java/com/apollographql/apollo3/compose Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import com.apollographql.apollo3.api.Operation
11
11
import com.apollographql.apollo3.api.Query
12
12
import com.apollographql.apollo3.cache.normalized.watch
13
13
import com.apollographql.apollo3.exception.ApolloException
14
+ import com.benasher44.uuid.uuid4
15
+ import kotlinx.coroutines.flow.catch
14
16
import kotlin.coroutines.CoroutineContext
15
17
import kotlin.coroutines.EmptyCoroutineContext
16
18
@@ -35,6 +37,7 @@ import kotlin.coroutines.EmptyCoroutineContext
35
37
fun <D : Operation .Data > ApolloCall<D>.toState (context : CoroutineContext = EmptyCoroutineContext ): State <ApolloResponse <D >? > {
36
38
val responseFlow = remember {
37
39
toFlow()
40
+ .catch { emit(ApolloResponse .Builder (operation, uuid4(), it as ? ApolloException ? : throw it).build()) }
38
41
}
39
42
return responseFlow.collectAsState(initial = null , context = context)
40
43
}
@@ -59,6 +62,7 @@ fun <D : Operation.Data> ApolloCall<D>.toState(context: CoroutineContext = Empty
59
62
fun <D : Query .Data > ApolloCall<D>.watchAsState (context : CoroutineContext = EmptyCoroutineContext ): State <ApolloResponse <D >? > {
60
63
val responseFlow = remember {
61
64
watch()
65
+ .catch { emit(ApolloResponse .Builder (operation, uuid4(), it as ? ApolloException ? : throw it).build()) }
62
66
}
63
67
return responseFlow.collectAsState(initial = null , context = context)
64
68
}
You can’t perform that action at this time.
0 commit comments