Skip to content

Commit 9fba44a

Browse files
committed
Update sample Storefront API version
1 parent c2ef02f commit 9fba44a

214 files changed

Lines changed: 8422 additions & 9911 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

platforms/android/samples/MobileBuyIntegration/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
STOREFRONT_DOMAIN=<yourdomainhere.myshopify.com>
22
STOREFRONT_ACCESS_TOKEN=<storefront access token>
3-
API_VERSION=2025-07
3+
API_VERSION=2026-04
44

55
CUSTOMER_ACCOUNT_API_CLIENT_ID=<configured customer account api client id>
66
CUSTOMER_ACCOUNT_API_REDIRECT_URI=shop.<shop id>.app://callback

platforms/android/samples/MobileBuyIntegration/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Edit `.env`:
7777
```text
7878
STOREFRONT_DOMAIN=your-store.myshopify.com
7979
STOREFRONT_ACCESS_TOKEN=your-token
80-
API_VERSION=2025-07
80+
API_VERSION=2026-04
8181
```
8282

8383
Optional values enable Customer Account API and buyer identity demo flows:

platforms/android/samples/MobileBuyIntegration/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def properties = loadProperties()
2323
// Storefront API
2424
def storefrontDomain = properties.getProperty("STOREFRONT_DOMAIN")
2525
def accessToken = properties.getProperty("STOREFRONT_ACCESS_TOKEN")
26-
def apiVersion = properties.getProperty("API_VERSION", "2025-07")
26+
def apiVersion = properties.getProperty("API_VERSION", "2026-04")
2727

2828
// Customer Account API
2929
def customerAccountApiClientId = properties.getProperty("CUSTOMER_ACCOUNT_API_CLIENT_ID")

platforms/android/samples/MobileBuyIntegration/app/src/main/graphql/schema.graphqls

Lines changed: 205 additions & 176 deletions
Large diffs are not rendered by default.

platforms/android/samples/MobileBuyIntegration/app/src/main/java/com/shopify/checkout_kit_mobile_buy_integration_sample/common/client/StorefrontApiClient.kt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.shopify.checkout_kit_mobile_buy_integration_sample.common.client
22

33
import com.apollographql.apollo.ApolloClient
4+
import com.apollographql.apollo.api.ApolloResponse
5+
import com.apollographql.apollo.api.Operation
46
import com.apollographql.apollo.api.Optional
57
import com.shopify.checkout_kit_mobile_buy_integration_sample.graphql.CartCreateMutation
68
import com.shopify.checkout_kit_mobile_buy_integration_sample.graphql.CartLinesAddMutation
@@ -25,47 +27,61 @@ class StorefrontApiClient(
2527
cursor = Optional.presentIfNotNull(cursor),
2628
)
2729
).execute()
28-
return response.dataOrThrow()
30+
return response.dataOrThrowWithErrors()
2931
}
3032

3133
suspend fun fetchProduct(productId: String, numVariants: Int): FetchProductQuery.Data {
3234
val response = apollo.query(
3335
FetchProductQuery(productId = productId, numVariants = numVariants)
3436
).execute()
35-
return response.dataOrThrow()
37+
return response.dataOrThrowWithErrors()
3638
}
3739

3840
suspend fun fetchCollections(numCollections: Int, numProducts: Int): FetchCollectionsQuery.Data {
3941
val response = apollo.query(
4042
FetchCollectionsQuery(numCollections = numCollections, numProducts = numProducts)
4143
).execute()
42-
return response.dataOrThrow()
44+
return response.dataOrThrowWithErrors()
4345
}
4446

4547
suspend fun fetchCollection(handle: String, numProducts: Int): FetchCollectionQuery.Data {
4648
val response = apollo.query(
4749
FetchCollectionQuery(handle = handle, numProducts = numProducts)
4850
).execute()
49-
return response.dataOrThrow()
51+
return response.dataOrThrowWithErrors()
5052
}
5153

5254
suspend fun createCart(input: CartInput): CartCreateMutation.Data {
5355
val response = apollo.mutation(CartCreateMutation(input = input)).execute()
54-
return response.dataOrThrow()
56+
return response.dataOrThrowWithErrors()
5557
}
5658

5759
suspend fun cartLinesAdd(cartId: String, lines: List<CartLineInput>): CartLinesAddMutation.Data {
5860
val response = apollo.mutation(CartLinesAddMutation(cartId = cartId, lines = lines)).execute()
59-
return response.dataOrThrow()
61+
return response.dataOrThrowWithErrors()
6062
}
6163

6264
suspend fun cartLinesUpdate(cartId: String, lines: List<CartLineUpdateInput>): CartLinesUpdateMutation.Data {
6365
val response = apollo.mutation(CartLinesUpdateMutation(cartId = cartId, lines = lines)).execute()
64-
return response.dataOrThrow()
66+
return response.dataOrThrowWithErrors()
6567
}
6668

6769
suspend fun cartLinesRemove(cartId: String, lineIds: List<String>): CartLinesRemoveMutation.Data {
6870
val response = apollo.mutation(CartLinesRemoveMutation(cartId = cartId, lineIds = lineIds)).execute()
69-
return response.dataOrThrow()
71+
return response.dataOrThrowWithErrors()
72+
}
73+
74+
private fun <D : Operation.Data> ApolloResponse<D>.dataOrThrowWithErrors(): D {
75+
if (data == null) {
76+
val storefrontErrors = errors
77+
?.joinToString(separator = "; ") { error -> error.message }
78+
?.takeIf { errorMessages -> errorMessages.isNotBlank() }
79+
80+
if (storefrontErrors != null) {
81+
throw RuntimeException("Storefront API error: $storefrontErrors")
82+
}
83+
}
84+
85+
return dataOrThrow()
7086
}
7187
}

platforms/android/scripts/apollo_download_schema

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ npx -y dotenv-cli -e .env -- sh -c '
2424
fi
2525
if [ -z "$VERSION" ]; then
2626
echo "❌ API_VERSION is not set. Check your .env file."
27-
echo " Add API_VERSION=2025-07 to your .env"
27+
echo " Add API_VERSION=2026-04 to your .env"
2828
exit 1
2929
fi
3030

0 commit comments

Comments
 (0)