Skip to content

[sample] apollo 5 with minimal cache fix#216

Open
kiftio wants to merge 1 commit into
mainfrom
05-26-apollo_5_with_minimal_cache_fix
Open

[sample] apollo 5 with minimal cache fix#216
kiftio wants to merge 1 commit into
mainfrom
05-26-apollo_5_with_minimal_cache_fix

Conversation

@kiftio
Copy link
Copy Markdown
Contributor

@kiftio kiftio commented May 26, 2026

What changes are you making?

Upgrades the Apollo GraphQL dependency from apollo-runtime v4.4.3 to v5.0.0 and migrates the normalized cache to the new standalone com.apollographql.cache:normalized-cache library (v1.0.3). As part of this migration:

  • The Apollo cache is now configured using the new cache() builder extension with CacheKey.Scope.SERVICE and the normalized-cache-apollo-compiler-plugin is registered in the Apollo service configuration.
  • Query methods in StorefrontApiClient are converted from suspend functions returning single values to functions returning Flow, using FetchPolicy.CacheAndNetwork to serve cached data immediately while fetching fresh data in the background.
  • Repository and ViewModel layers are updated to expose and collect these flows, so the UI can reactively update when fresh network data arrives after an initial cache hit.
  • Error handling in ViewModels is updated to avoid overwriting an already-loaded UI state with an error when a background network refresh fails.
  • ProductViewModel preserves the currently selected variant and cart state when a product flow emits an updated value.

How to test

  1. Launch the sample app and navigate to the home screen — collections should load immediately from cache on subsequent visits, then refresh with network data.
  2. Open a collection and a product detail page and verify the same cache-then-network behaviour.
  3. Disable network connectivity after an initial load, relaunch the app, and confirm that cached data is displayed without an error state.
  4. Re-enable connectivity and confirm the UI updates with fresh data.
  5. On a product detail page, select a variant, trigger a background refresh, and confirm the selected variant and quantity are preserved after the update.

Before you merge

Important

  • I've added tests to support my implementation
  • I have read and agree with the Contribution Guidelines
  • I have read and agree with the Code of Conduct
  • I've updated the relevant platform README (platforms/swift/README.md and/or platforms/android/README.md)

Releasing a new Swift version?
  • I have bumped the version in ShopifyCheckoutKit.podspec
  • I have bumped the version in platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift
  • I have updated platforms/swift/CHANGELOG.md
  • I have updated the SwiftPM/CocoaPods version snippets in platforms/swift/README.md (major version only)
Releasing a new Android version?
  • I have bumped the versionName in platforms/android/lib/build.gradle
  • I have updated platforms/android/CHANGELOG.md
  • I have updated the Gradle/Maven version snippets in platforms/android/README.md

Tip

See the Contributing documentation for the full release process per platform.

Copy link
Copy Markdown
Contributor Author

kiftio commented May 26, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

React Native — Coverage Report

Lines Statements Branches Functions
Coverage: 98%
96.76% (239/247) 91.02% (142/156) 100% (64/64)

@kiftio kiftio changed the title apollo 5 with minimal cache fix [sample] apollo 5 with minimal cache fix May 26, 2026
@kiftio kiftio force-pushed the 05-26-apollo_5_with_minimal_cache_fix branch 2 times, most recently from 119110f to b6efe55 Compare May 26, 2026 16:03
@kiftio kiftio force-pushed the 05-26-apollo_5_with_minimal_cache_fix branch from b6efe55 to c30524e Compare May 26, 2026 16:08
@kiftio kiftio marked this pull request as ready for review May 26, 2026 16:08
@kiftio kiftio requested a review from a team as a code owner May 26, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant