contentful/apps

Shopify App: Product ID not correct

Closed this issue · 2 comments

I'm currently experiencing a good deal of confusion around IDs in Shopify's API.

The one that this plugin returns is a long string of around 48 characters. Example: Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzY1MzcxMjM1Mjg3NTY=.

However, the only ID I can seem to get Shopify's APIs (any of them, the storefront and the admin) to return are either short numeric (e.g. 6586511065140) or longer strings that are essentially gid versions with the same otherwise numeric (e.g. gid://shopify/Product/6586511065140).

In the past, Shopify's admin API was returning the former (the long 48 char version) but something has changed which has broken my site (incredibly frustrating!).

Is there no way for this plugin to use the shorter numeric or gid version of the ID?

Note that I was using the default product variant option for the plugin but have since switched the just the product option, though this problem existed before I made the change (and I thought that perhaps the change might solve the issue, but it did not).

Hey @jaymakes11,

Shopify introduced a change in its API: https://shopify.dev/api/release-notes/2022-04#non-encoded-object-ids-in-the-graphql-storefront-api
From version 2022-04, their api changed the format of the returned ids. The Shopify Contentful App uses version 2019-10 and therefore still returns the "old" id format.

You can specify the API version via the url. E.g. https://xxx.myshopify.com/api/2019-10/graphql. I assume you don't specify any version and therefore always use the latest version of the api.

Alternatively, you can base64 decode the id stored in Contentful. That way you receive the gid-URI.

Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzY1MzcxMjM1Mjg3NTY= -> gid://shopify/Product/6537123528756