As part of discussion in #588 decision was made to drop all Apollo sync operations.
com.apollographql.apollo.ApolloCall#execute
com.apollographql.apollo.ApolloPrefetch#execute
Any Rx wrappers should be built on top of com.apollographql.apollo.ApolloCall.Callback and com.apollographql.apollo.ApolloPrefetch.Callback now.
As for the tests there are 2 options: use Rx with blocking operations or create blocking implementation of callback.
EDIT: Coroutines are now an option as well: https://www.apollographql.com/docs/android/advanced/coroutines/
So how are we supposed to execute calls in kotlin coroutines?
Nevermind. I got this. If anyone has a problem with it just add this extension:
suspend fun <T> ApolloCall<T>.execute() = suspendCoroutine<Response<T>> { cont ->
enqueue(object: ApolloCall.Callback<T>() {
override fun onResponse(response: Response<T>) {
cont.resume(response)
}
override fun onFailure(e: ApolloException) {
cont.resumeWithException(e)
}
})
}
I really wish Apollo Android support synchronous calls because I feel like it imposes an implementation rule that the consumer must always call it by async means, instead of only when it's necessary.
Id also like synchronous api and choose threads myself
I find this decision very upsetting because using the asynchronous API is inconvenient as hell. Even worse, each call can return us more than one result.
Dealing with callbacks with gazillion of methods, some of which can be called multiple times, is hardly something I want to be doing. Even more so when writing interceptors since I can't even use coroutines there properly as these callbacks don't map to a flow of responses. As a result, I have to write really convoluted code to process all of that.
Why can't it be implemented the same way as it is done in OkHttp/Retrofit? Everything is so much easier there, especially with coroutines. I realize that there are extra cases with subscriptions, but shoehorning everything into the most general case even if you never use it is just jarring.
Most helpful comment
I really wish Apollo Android support synchronous calls because I feel like it imposes an implementation rule that the consumer must always call it by async means, instead of only when it's necessary.