Medium Oct 6, 2025

Medium Android App — Migrating from Apollo Kotlin 3 to 4: Lessons Learned

M3 Related OWASP risk: Insecure Authentication/Authorization Learn more →

Article Summary

Pierrick CAEN from Medium thought upgrading Apollo Kotlin would be straightforward. Instead, it exposed hidden cache issues that had been silently failing for months.

The Medium Android team migrated from Apollo Kotlin 3 to 4, discovering that the new version's stricter exception handling revealed fundamental problems with their GraphQL cache implementation. What started as a routine upgrade became a complete overhaul of their caching strategy.

Key Takeaways

Critical Insight

Upgrading Apollo Kotlin 4 forces you to fix cache configuration issues that were previously hidden, leading to more robust GraphQL implementations.

The article includes production-ready code for safe cache watchers and reveals two future optimizations Medium is considering for even better performance.

About This Article

Problem

Apollo Kotlin 4 started throwing CacheMissExceptions that version 3 had quietly ignored. This broke the Medium Android app's watch() functionality wherever FetchPolicy.CacheFirst was used, causing failures across the UI.

Solution

Pierrick CAEN added declarative cache IDs using @typePolicy and @fieldPolicy annotations. He set addTypename to 'always' in the Gradle build file and wrote safeWatch() extension functions that filter out expected exceptions based on the fetch policy type.

Impact

Cache hit rates improved noticeably once cache IDs matched types and fields correctly. The silent cache misses that had been a problem in their GraphQL implementation went away, leaving them with a more reliable caching strategy.