Eduard Boloș
09/20/2022, 3:52 PMapolloCall.execute()
, in case of a network error (e.g. no internet, backend down), instead of a ApolloNetworkException
to be raised, I get java.util.NoSuchElementException: Flow is empty
. Which I can see being thrown by the .first()
in `execute`'s implementation. This happens although I can see clearly that a ApolloNetworkException
is thrown in DefaultHttpEngine.execute()
. Am I doing something wrong? Or what might be happening?mbonnin
09/20/2022, 3:58 PMmbonnin
09/20/2022, 3:58 PMEduard Boloș
09/20/2022, 4:00 PMmbonnin
09/20/2022, 4:00 PMmbonnin
09/20/2022, 4:02 PMmbonnin
09/20/2022, 4:03 PMApolloNetworkException
is caught somewhere and makes the .first()
fail 🤔mbonnin
09/20/2022, 4:04 PM.watch()
or anything like that, right?mbonnin
09/20/2022, 4:04 PM.watch()
ignores errors by default)Eduard Boloș
09/20/2022, 4:04 PMmbonnin
09/20/2022, 4:04 PMEduard Boloș
09/20/2022, 4:05 PMLooks like theYeah, that seems to be the case, actually. Even if I dois caught somewhereApolloNetworkException
toFlow().catch { Log.e(TAG, "error", it) }
, nothing ever gets logged.mbonnin
09/20/2022, 4:16 PMApolloNetworkException
as expected https://github.com/apollographql/apollo-kotlin/commit/95ce6b84e71958fe8b4b9c2d1c7cc3a5612778ecmbonnin
09/20/2022, 4:16 PMfun networkOnly() = runTest(before = { setUp() }, after = { tearDown() }) {
val query = HeroNameQuery()
val data = HeroNameQuery.Data(HeroNameQuery.Hero("R2-D2"))
val call = apolloClient.query(query).fetchPolicy(FetchPolicy.NetworkOnly)
// First query should hit the network and save in cache
mockServer.enqueue(query, data)
val response = call.execute()
Eduard Boloș
09/20/2022, 4:16 PMEduard Boloș
09/20/2022, 4:20 PMcatch
blockEduard Boloș
09/20/2022, 4:20 PMmbonnin
09/20/2022, 4:20 PMEduard Boloș
09/20/2022, 4:21 PMmbonnin
09/20/2022, 4:21 PM