Launch Apollo Studio

Kotlin native


Apollo Kotlin is built for multiplatform and therefore supports iOS, MacOS, and other Darwin targets.

Because the current Kotlin memory model requires freezing objects that are accessed from multiple threads (docs), there are some limitations.

In particular, you must create your ApolloClient and call query and other operations from the main thread. Apollo Kotlin then executes the work on a background thread and returns the result to the main thread.

Multithreaded coroutines

By default when using the x.y.z-native-mt branch of coroutines, Gradle replaces the -native-mt version with the non-mt version as outlined here. To prevent this, add the following to your root build.gradle.kts:

allprojects {
  configurations {
    all {
      resolutionStrategy {
        force("org.jetbrains.kotlinx:kotlinx-coroutines-core:x.y.z-native-mt")
      }
    }
  }
}

This ensures that the same version is used everywhere, and that Gradle doesn't fail because -native-mt is a pre-release version (1.5.1-native-mt < 1.5.1).

Edit on GitHub