Hey guys. Starting to work with apollo3 and KMM. I...
# apollo-kotlin
v
Hey guys. Starting to work with apollo3 and KMM. I'm wondering why this is an assertion during execution
Copy code
assertMainThreadOnNative()
if I'm trying to execute a query. Why am I forced to do it on the main thread?
m
Hi 👋 That's a long story with some details here. The tldr; is that when we started, multithreaded coroutines were super experimental and we wanted to make everything work with the regular coroutines artifact
Everything is still executed on a background thread so it hasn't been a big limitation so far.
Also, something else is that there is no blocking call with
NSUrlSession
so you get a callback in a dispatch queue from where you need to resume a coroutine.
If that coroutine is the main thread then it's easy to get
dispatch_main_queue()
. If it's not, then it's not the same story
v
wow thanks @mbonnin for the quick response. I'll take a look
m
Sure thing. Let us know if you have a different use case, we can look into it.