Got a question about execute() on an ApolloCall. ...
# apollo-kotlin
s
Got a question about execute() on an ApolloCall. Before, there was one place where we did a simply fire and forget enqueue where I can see in the signature it only throws an exception when the call has already been executed, so we were pretty confident(right?) that one of the two callbacks would be called for sure. Now in 3.x we’ve changed it to execute() and then handle the same cases, but I was wondering, are we guaranteed for either of the two cases to be called now? For starters the coroutine could get cancelled inbetween so in that case I assume we won’t get any response, but even without cancellation, other things could go bad, like a parsing exception or whatever, and it would still not reach the
also
block right? In general I was thinking about this and I realize I can’t answer this question with much confidence, so I thought I’d ask here 😄
b
Definitely,
execute()
can throw - that will be the case for network errors, so a fairly common one!
hasErrors
is specifically for GraphQL backend level errors.
in that case indeed the
also
here won't be called 🙂 There's also
dataAssertNoErrors
which can help handle all error cases in the same catch block
(Not sure if you've seen this doc but it explains this in more details)
s
Amazing, thanks for the response and the docs link! I’ve definitely seen this before but I forget things 😄
👍 1
😅 1