---
title: "Medium Android App — Migrating from Apollo Kotlin 3 to 4: Lessons Learned"
description: "Upgrading Medium's Android app from Apollo Kotlin 3 to 4 surfaced CacheMissException errors across every watch()-based UI, because v4 delivers fetch errors through ApolloResponse instead of throwing or silently dropping them."
url: "https://swe.quest/articles/medium-android-app-migrating-from-apollo-kotlin-3-to-4-lessons-learned-a49ead8ba5186c2f"
canonical: "https://medium.engineering/medium-android-app-migrating-from-apollo-kotlin-3-to-4-lessons-learned-ff8d0d861cdb"
source: "Medium Engineering"
published: "2025-10-06"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["graphql","mobile","caching","jvm","refactoring"]
---

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

A post on [Medium Engineering](https://swe.quest/sources/medium-eng.md), published 2025-10-06, 7 min read, Case study. Original: [https://medium.engineering/medium-android-app-migrating-from-apollo-kotlin-3-to-4-lessons-learned-ff8d0d861cdb](https://medium.engineering/medium-android-app-migrating-from-apollo-kotlin-3-to-4-lessons-learned-ff8d0d861cdb)

## Summary

Upgrading Medium's Android app from Apollo Kotlin 3 to 4 surfaced CacheMissException errors across every watch()-based UI, because v4 delivers fetch errors through ApolloResponse instead of throwing or silently dropping them. The root cause was a flawed programmatic CacheKeyGenerator, fixed by switching to declarative @typePolicy/@fieldPolicy cache IDs and adding \_\_typename to all operations. A safeWatch wrapper filters expected exceptions per fetch policy (cache misses under CacheFirst/CacheAndNetwork, network errors under NetworkFirst) so the UI only sees meaningful failures. Fragment cache-update extension functions, a custom Currency scalar adapter, and planned HTTP batching and persisted queries round out the upgrade.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [GraphQL](https://swe.quest/tags/graphql.md) (Backend & APIs)
- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)
- [Caching](https://swe.quest/tags/caching.md) (Backend & APIs)
- [Java & JVM](https://swe.quest/tags/jvm.md) (Languages)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)

## Prerequisites

- GraphQL basics ([easy posts on GraphQL](https://swe.quest/tags/graphql.md?difficulty=easy))
- Kotlin coroutines and Flow ([easy posts on Java & JVM](https://swe.quest/tags/jvm.md?difficulty=easy))
- Apollo normalized cache ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))

## Keywords

Apollo Kotlin, Android, Kotlin, GraphQL, Medium

## Related posts

- [Migrating from Apollo Tooling to GraphQL Codegen at Yelp](https://swe.quest/articles/migrating-from-apollo-tooling-to-graphql-codegen-at-yelp-732b107d437979cc.md): Yelp Engineering · 2026-07-16 · Medium · 11 min read · GraphQL, TypeScript, Build systems, Refactoring & migrations, Open source
  Yelp replaced the deprecated apollo-tooling codegen with GraphQL Codegen across a 500+ package React/TypeScript monorepo without requiring developers to change imports or queries.
- [Apollo Cache is Your Friend, If You Get To Know It](https://swe.quest/articles/apollo-cache-is-your-friend-if-you-get-to-know-it-2ce614128099fb3f.md): Shopify Engineering · 2022-11-09 · Medium · 15 min read · GraphQL, Caching, Frontend, Memory management
  Apollo Client's InMemoryCache stores a normalized, in-session representation of GraphQL data, and its object lifecycle runs through four stages: fetching (governed by fetch policies, defaulting to cache-first), normalization (splitting responses into objects keyed by \_\_typename plus id or custom keyFields into a flat hash map), updating and merging, and garbage collection and eviction.
- [Improving Shopify App’s Performance](https://swe.quest/articles/improving-shopify-app-s-performance-3211dcd650ae34c6.md): Shopify Engineering · 2024-03-05 · Medium · 8 min read · Mobile, React, Performance engineering, Caching
  Shopify cut its React Native mobile app's P75 launch time by 44% and screen load times by 59% over 2023, against targets of 2s launch and 500ms critical-screen loads.
- [Lessons From Building Android Widgets](https://swe.quest/articles/lessons-from-building-android-widgets-3b8b116282223e62.md): Shopify Engineering · 2022-09-22 · Medium · 19 min read · Mobile, Caching
  Shopify built its Android analytics widgets natively rather than in React Native, because widgets must be built from RemoteViews, which React Native does not support.
- [It’s a non-transitive R class world](https://swe.quest/articles/it-s-a-non-transitive-r-class-world-dc7be71b63e01554.md): Slack Engineering · 2023-02-01 · Medium · 5 min read · Mobile, Build systems, Refactoring & migrations, Static analysis, Developer productivity
  Slack migrated its 400+ module Android codebase to non-transitive R classes, where each module's R class contains only its own resources, yielding ~14% faster incremental builds after resource or layout changes and an ~8.5% (about 5.5MB) APK/DEX size reduction.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
