Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
STOREFRONT_DOMAIN=<yourdomainhere.myshopify.com>
STOREFRONT_ACCESS_TOKEN=<storefront access token>
API_VERSION=2025-07
API_VERSION=2026-04

CUSTOMER_ACCOUNT_API_CLIENT_ID=<configured customer account api client id>
CUSTOMER_ACCOUNT_API_REDIRECT_URI=shop.<shop id>.app://callback
Expand Down
2 changes: 1 addition & 1 deletion platforms/android/samples/MobileBuyIntegration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Edit `.env`:
```text
STOREFRONT_DOMAIN=your-store.myshopify.com
STOREFRONT_ACCESS_TOKEN=your-token
API_VERSION=2025-07
API_VERSION=2026-04
```

Optional values enable Customer Account API and buyer identity demo flows:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def properties = loadProperties()
// Storefront API
def storefrontDomain = properties.getProperty("STOREFRONT_DOMAIN")
def accessToken = properties.getProperty("STOREFRONT_ACCESS_TOKEN")
def apiVersion = properties.getProperty("API_VERSION", "2025-07")
def apiVersion = properties.getProperty("API_VERSION", "2026-04")

// Customer Account API
def customerAccountApiClientId = properties.getProperty("CUSTOMER_ACCOUNT_API_CLIENT_ID")
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.shopify.checkout_kit_mobile_buy_integration_sample.common.client

import com.apollographql.apollo.ApolloClient
import com.apollographql.apollo.api.ApolloResponse
import com.apollographql.apollo.api.Operation
import com.apollographql.apollo.api.Optional
import com.shopify.checkout_kit_mobile_buy_integration_sample.graphql.CartCreateMutation
import com.shopify.checkout_kit_mobile_buy_integration_sample.graphql.CartLinesAddMutation
Expand All @@ -25,47 +27,61 @@ class StorefrontApiClient(
cursor = Optional.presentIfNotNull(cursor),
)
).execute()
return response.dataOrThrow()
return response.dataOrThrowWithErrors()
}

suspend fun fetchProduct(productId: String, numVariants: Int): FetchProductQuery.Data {
val response = apollo.query(
FetchProductQuery(productId = productId, numVariants = numVariants)
).execute()
return response.dataOrThrow()
return response.dataOrThrowWithErrors()
}

suspend fun fetchCollections(numCollections: Int, numProducts: Int): FetchCollectionsQuery.Data {
val response = apollo.query(
FetchCollectionsQuery(numCollections = numCollections, numProducts = numProducts)
).execute()
return response.dataOrThrow()
return response.dataOrThrowWithErrors()
}

suspend fun fetchCollection(handle: String, numProducts: Int): FetchCollectionQuery.Data {
val response = apollo.query(
FetchCollectionQuery(handle = handle, numProducts = numProducts)
).execute()
return response.dataOrThrow()
return response.dataOrThrowWithErrors()
}

suspend fun createCart(input: CartInput): CartCreateMutation.Data {
val response = apollo.mutation(CartCreateMutation(input = input)).execute()
return response.dataOrThrow()
return response.dataOrThrowWithErrors()
}

suspend fun cartLinesAdd(cartId: String, lines: List<CartLineInput>): CartLinesAddMutation.Data {
val response = apollo.mutation(CartLinesAddMutation(cartId = cartId, lines = lines)).execute()
return response.dataOrThrow()
return response.dataOrThrowWithErrors()
}

suspend fun cartLinesUpdate(cartId: String, lines: List<CartLineUpdateInput>): CartLinesUpdateMutation.Data {
val response = apollo.mutation(CartLinesUpdateMutation(cartId = cartId, lines = lines)).execute()
return response.dataOrThrow()
return response.dataOrThrowWithErrors()
}

suspend fun cartLinesRemove(cartId: String, lineIds: List<String>): CartLinesRemoveMutation.Data {
val response = apollo.mutation(CartLinesRemoveMutation(cartId = cartId, lineIds = lineIds)).execute()
return response.dataOrThrow()
return response.dataOrThrowWithErrors()
}

private fun <D : Operation.Data> ApolloResponse<D>.dataOrThrowWithErrors(): D {
if (data == null) {
val storefrontErrors = errors
?.joinToString(separator = "; ") { error -> error.message }
?.takeIf { errorMessages -> errorMessages.isNotBlank() }

if (storefrontErrors != null) {
throw RuntimeException("Storefront API error: $storefrontErrors")
}
}

return dataOrThrow()
}
}
2 changes: 1 addition & 1 deletion platforms/android/scripts/apollo_download_schema
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ npx -y dotenv-cli -e .env -- sh -c '
fi
if [ -z "$VERSION" ]; then
echo "❌ API_VERSION is not set. Check your .env file."
echo " Add API_VERSION=2025-07 to your .env"
echo " Add API_VERSION=2026-04 to your .env"
exit 1
fi

Expand Down
Loading
Loading