Skip to content

AC Storefront: GraphQL values Sendable#88

Open
kieran-osgood-shopify wants to merge 1 commit into
kieran-osgood/swift6/generated-model-sendablefrom
kieran-osgood/swift6/storefront-sendable-cache
Open

AC Storefront: GraphQL values Sendable#88
kieran-osgood-shopify wants to merge 1 commit into
kieran-osgood/swift6/generated-model-sendablefrom
kieran-osgood/swift6/storefront-sendable-cache

Conversation

@kieran-osgood-shopify

@kieran-osgood-shopify kieran-osgood-shopify commented May 13, 2026

Copy link
Copy Markdown
Contributor

What changes are you making?

Important

When reviewing, consider these changes alongside the ones in #274.
#88 highlighted an issue with ObservableObjects + Swift Concurrency that makes it awkward from a library perspective.
To head off future issues and to encourage consistency in the API, I've added #274 as a recommended but not "essential" step in the Swift 6 migration

This PR makes the Storefront/GraphQL checkout path safe to use from Swift concurrency contexts by tightening Sendable boundaries around the Storefront client, cache, request/response values, and test doubles.

Warning

This intentionally includes a breaking Swift API change: ShopifyAcceleratedCheckouts.Customer is now a Sendable value type instead of an ObservableObject class.

Customer is checkout identity data, not independently-owned UI state. Modeling it as an immutable struct matches normal Swift/SwiftUI patterns: app/configuration state owns and publishes values, while async/network code receives safe value snapshots.

Consumers should continue to observe the configuration object and assign a new customer value when inputs change:

@StateObject private var configuration = ShopifyAcceleratedCheckouts.Configuration(
    storefrontDomain: EnvironmentVariables.storefrontDomain,
    storefrontAccessToken: EnvironmentVariables.storefrontAccessToken
)

configuration.customer = ShopifyAcceleratedCheckouts.Customer(
    email: email.isEmpty ? nil : email,
    phoneNumber: phone.isEmpty ? nil : phone
)

The sample app was updated to use this pattern in:

platforms/swift/Samples/ShopifyAcceleratedCheckoutsApp/ShopifyAcceleratedCheckoutsApp/ShopifyAcceleratedCheckoutsApp.swift

This removes the need for an internal CustomerIdentity wrapper and lets Storefront cart creation accept Customer? directly.

How to test

Validated locally:

  • dev swift test
  • dev swift lint
  • dev swift api check
  • dev swift build samples

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 platforms/swift/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.

kieran-osgood-shopify commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

React Native — Coverage Report

Lines Statements Branches Functions
Coverage: 92%
91.66% (319/348) 87.86% (181/206) 100% (82/82)

@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/storefront-sendable-cache branch from aecdfa8 to a2a8f7d Compare June 11, 2026 08:54
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/generated-model-sendable branch from 08574c6 to 92ab70f Compare June 11, 2026 08:54
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/storefront-sendable-cache branch 2 times, most recently from 3dce64e to 3dbd021 Compare June 11, 2026 10:01
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/generated-model-sendable branch 2 times, most recently from 65f806c to 5678177 Compare June 11, 2026 10:23
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/storefront-sendable-cache branch from 3dbd021 to 3afa77a Compare June 11, 2026 10:23
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/generated-model-sendable branch from 5678177 to 679b65c Compare June 11, 2026 10:32
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/storefront-sendable-cache branch from 3afa77a to 37a6f41 Compare June 11, 2026 10:32
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/generated-model-sendable branch from 679b65c to d8af537 Compare June 11, 2026 13:08
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/storefront-sendable-cache branch 3 times, most recently from 70f862a to c1ee065 Compare June 11, 2026 15:57
@kieran-osgood-shopify kieran-osgood-shopify marked this pull request as ready for review June 12, 2026 09:08
@kieran-osgood-shopify kieran-osgood-shopify requested a review from a team as a code owner June 12, 2026 09:08
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/storefront-sendable-cache branch from c1ee065 to 4d18fd7 Compare June 12, 2026 10:58
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/generated-model-sendable branch 2 times, most recently from 4f87743 to 7392cb4 Compare June 12, 2026 12:54
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/storefront-sendable-cache branch from 4d18fd7 to 50f73e7 Compare June 12, 2026 12:54
@kieran-osgood-shopify kieran-osgood-shopify changed the base branch from kieran-osgood/swift6/generated-model-sendable to graphite-base/88 June 12, 2026 14:11
/// Helper type for encoding/decoding Any values
struct AnyCodable: Codable {
let value: Any
private enum GraphQLJSONValue: Sendable {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactoring away Any usage so that its Sendable

@kieran-osgood-shopify kieran-osgood-shopify changed the title Make Storefront cache and GraphQL values Sendable AC Storefront: GraphQL values Sendable Jun 12, 2026
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/storefront-sendable-cache branch from 50f73e7 to 230c9ac Compare June 12, 2026 15:08
@kieran-osgood-shopify kieran-osgood-shopify changed the base branch from graphite-base/88 to kieran-osgood/swift6/generated-model-sendable June 12, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:50662 Rebase Checkout Kit on UCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant