Engineering
apollo-kotlin avatar

apollo-kotlin

Guide for building applications with Apollo Kotlin, the GraphQL client library for Android, JVM, and Kotlin Multiplatform (KMP).

Introduction

The Apollo Kotlin skill provides a comprehensive framework for integrating GraphQL into Android, JVM, and Kotlin Multiplatform (KMP) projects using the Apollo Kotlin library (v4+). Designed for mobile and backend developers, this skill streamlines the process of generating type-safe Kotlin models from GraphQL operations and schemas, ensuring robust data handling across heterogeneous platforms. It bridges the gap between client-side requirements and remote GraphQL services by managing the entire lifecycle of a request, from initial configuration to runtime execution and cache management.

  • Configure Apollo Kotlin in Gradle projects, including support for Android, JVM, and KMP modules.

  • Manage GraphQL schema downloads and code generation settings, including custom scalar mapping and adapter configuration.

  • Build and customize the ApolloClient with interceptors for authentication, request logging, and error handling.

  • Implement efficient data retrieval patterns, including queries, mutations, and reactive subscriptions using Kotlin Flows.

  • Set up and leverage the normalized cache for offline-first capabilities, optimized state management, and consistency across application screens.

  • Facilitate development with script helpers to manage and update Apollo Kotlin library versions and cache dependencies.

  • Ensure all schema and operation files are committed to source control for reproducible builds.

  • Prefer using the modern com.apollographql.cache libraries over older alternatives for optimal performance.

  • Use the provided scripts to list available versions of Apollo Kotlin and the normalized cache before upgrading.

  • Apply @typePolicy directives to define custom cache keys for complex objects, ensuring the normalized cache functions correctly.

  • Always use Apollo Kotlin v4 or later to take advantage of the latest performance improvements, API stability, and feature sets.

  • Validate all network-bound logic with integrated testing and appropriate error handling to distinguish between network failures and GraphQL-specific errors.

Repository Stats

Stars
58
Forks
4
Open Issues
2
Language
Shell
Default Branch
main
Sync Status
Idle
Last Synced
May 3, 2026, 06:36 PM
View on GitHub