In API version 2022-04, using Base64-encoded object IDs as arguments to fields and mutations was deprecated. Support for this behavior will be removed in API version 2023-07.

This guide shows you to migrate your app from using Base64-encoded object IDs to non-encoded object IDs.

## Requirements

You need to migrate your app if you're caching or parsing IDs, or persisting IDs to a database.

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.

## Step 1: Migrate your app

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:

<p>
<div class="react-code-block" data-preset="output">
<div class="react-code-block-preload ">
<div class="react-code-block-preload-bar "></div>
<div class="react-code-block-preload-placeholder-container">
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>

</div>
</div>

<script data-option="title" data-value="GraphQL Admin API"></script>

<script type="text/plain" data-language="json">
RAW_MD_CONTENT"gid://shopify/Product/1"
END_RAW_MD_CONTENT</script>

</div>
</p>


<p>
<div class="react-code-block" data-preset="output">
<div class="react-code-block-preload ">
<div class="react-code-block-preload-bar "></div>
<div class="react-code-block-preload-placeholder-container">
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>

</div>
</div>

<script data-option="title" data-value="GraphQL Storefront API"></script>

<script type="text/plain" data-language="json">
RAW_MD_CONTENT"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE="
END_RAW_MD_CONTENT</script>

</div>
</p>


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:

<p>
<div class="react-code-block" data-preset="terminal">
<div class="react-code-block-preload ThemeMode-dim">
<div class="react-code-block-preload-bar "></div>
<div class="react-code-block-preload-placeholder-container">
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>

</div>
</div>

<script data-option="title" data-value="POST https://{shop}.myshopify.com/api/{api_version}/graphql.json"></script>

<script type="text/plain" data-language="graphql">
RAW_MD_CONTENT{
  product(id: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE=") {
    id
  }
}
END_RAW_MD_CONTENT</script>

</div>
</p>

<p>
<div class="react-code-block" data-preset="terminal">
<div class="react-code-block-preload ThemeMode-dim">
<div class="react-code-block-preload-bar "></div>
<div class="react-code-block-preload-placeholder-container">
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>

</div>
</div>

<script data-option="title" data-value="POST https://{shop}.myshopify.com/api/{api_version}/graphql.json"></script>

<script type="text/plain" data-language="graphql">
RAW_MD_CONTENT{
  product(id: "gid://shopify/Product/1") {
    id
  }
}
END_RAW_MD_CONTENT</script>

</div>
</p>


## Step 2: 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:

<p>
<div class="react-code-block" data-preset="file">
<div class="react-code-block-preload ThemeMode-dim">
<div class="react-code-block-preload-bar "></div>
<div class="react-code-block-preload-placeholder-container">
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>
<div class="react-code-block-preload-code-container">
<div class="react-code-block-preload-codeline-number"></div>
<div class="react-code-block-preload-codeline"></div>
</div>

</div>
</div>


<script type="text/plain" data-language="ruby">
RAW_MD_CONTENTrequire 'base64'

Product.in_batches.each_record do |product|
  encoded_id = product.shopify_id # Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE=
  decoded_id = Base64.strict_decode64(encoded_id)
  product.shopify_id = decoded_id # gid://shopify/Product/1
  product.save!
end
END_RAW_MD_CONTENT</script>

</div>
</p>


## Next steps

- If you have questions or need help migrating your app, refer to Shopify's [Storefront API Feedback GitHub discussion board](https://github.com/Shopify/storefront-api-feedback).