mateusz.kwiecinski
10/27/2023, 8:38 PMAutoPersistedQueriesNotSupported
exception and gracefully recover from it, like Martin suggested.
For latest v4 beta the simplest thing I'm able to think of is to resemble v3's behavior by doing something like:
chain.proceed(request)
.onEach { response ->
(response.exception as? AutoPersistedQueriesNotSupported)?.let { throw it }
}
.catch { throwable ->
if(throwable is AutoPersistedQueriesNotSupported) {
emitAll(chain.proceed(request.newBuilder().enableAutoPersistedQueries(false).build())
} else {
throw throwable
}
}
but maybe there are better alternatives now, not requiring artificial exception being thrown?bod
10/30/2023, 8:34 AMreturn chain.proceed(request)
.flatMapConcat { response ->
if (response.exception is AutoPersistedQueriesNotSupported) {
chain.proceed(request.newBuilder().enableAutoPersistedQueries(false).build())
} else {
flowOf(response)
}
}
bod
10/30/2023, 8:37 AMreturn flow {
chain.proceed(request).collect { response ->
if (response.exception is AutoPersistedQueriesNotSupported) {
emitAll(chain.proceed(request.newBuilder().enableAutoPersistedQueries(false).build()))
} else {
emit(response)
}
}
}
mateusz.kwiecinski
10/30/2023, 10:37 AMflatMapConcat
approach assumes the upstream will not emit any subsequent updates and will complete immediately. If by any chance you decided to change the implementation and not complete the flow this wouldn't work. But I guess it's safe to assume this is the contract 👀 Thanks 👍bod
10/30/2023, 10:42 AM