Architecting the Shared Layer: GraphQL Best Practices in Kotlin Multiplatform
Clean Architecture in Kotlin Multiplatform needs a robust data layer that keeps complexity away from the UI. Bring GraphQL into the mix and the challenge becomes keeping a strict separation of concerns while still using the full power of the graph on Android and iOS.
This lightning talk explores patterns for integrating Apollo Kotlin directly into the commonMain source set, treating the shared KMP module as the single source of truth so that each platform's UI stays purely reactive. For the full setup, see the longer session "Write Once, Query Everywhere".
Key takeaways
Shared normalized cache
Apollo's cache in the shared data layer as one offline-first source of truth that keeps Android and iOS in sync.
Schema-driven modularity
Generated GraphQL models stay in the data layer; mappers expose pure domain entities, so API details never leak into business logic.
Type-safe error boundaries
A unified Result wrapper in the shared repository turns GraphQL partial failures into clean domain states for the UI.