Migrate your app to use non-encoded object IDs
Currently, Shopify serves Base64-encoded object IDs from the GraphQL Storefront API.
As of January 3, 2022, Shopify will begin serving non-encoded object IDs from the
unstable version of the GraphQL Storefront API. The upcoming
2022-04 release will be the first stable version that doesn't serve Base64-encoded object IDs.
This guide shows you to migrate your app from using Base64-encoded object IDs to non-encoded object IDs.
How object IDs work
Most object types in Shopify's GraphQL APIs have an
id field. The
id field represents the globally-unique identifier for an individual record. The following are examples of a product ID in the GraphQL Admin and Storefront APIs before the change:
Do I need to migrate my app?
If your app queries the Storefront API and uses the object IDs as they're given without any long-term persistence or transformations, then you don't have to migrate your app. However, if you're caching, persisting to a database, or parsing IDs, then you need to migrate your app.
Migrate your app
To help you migrate your app, Shopify has changed the GraphQL Storefront API to allow for non-encoded object IDs to be used interchangeably as arguments to fields and mutations. For example, the following two queries are now valid and return identical responses:
Handle persisted IDs
If you have a database of persisted object IDs, then there are a few possible migration strategies.
Base64 encoding and decoding is commonly a part of most programming standard libraries, and if not, readily available as a 3rd-party package. You can write a script that iterates through each record, removes the Base64 encoding, and updates the database. The following example shows what a script written in Ruby could look like:
- If you have questions or need help migrating your app, refer to Shopify's Storefront API Feedback GitHub discussion board.