Migrating from Shopify API 2023-07 (REST) to GraphQL: Issues with Deprecated Product Variant Fields

Hi everyone,

I’m working on updating an old service at my company that syncs products with Shopify. The service is quite outdated, and I need to ensure that deprecated API calls don’t break our functionality. Here’s some context:

Rails: 6.0.3

Ruby: 2.7.4

shopify-api-ruby: 9.5.1 → Upgraded to 13.4.0

Shopify API version : 2023-07

Currently using REST API, not GraphQL

After upgrading to shopify-api-ruby 13.4.0 (which is the highest version I can use with Ruby 2.7), many existing API calls broke due to changes in function signatures and response structures.

Issue 1: Product Metafields Returning nil

Previously, this code worked fine on 9.5.1:

# shopify-api-ruby 9.5.1
product = ShopifyAPI::Product.find(xxxxxxx)
pp product.metafields  # Returns metafields correctly

However, after upgrading:

# shopify-api-ruby 13.4.0
product = ShopifyAPI::Product.find(id: xxxxxxx)
pp product.metafields  # Returns nil

Why is this happening? Do I need to make an extra API call to fetch metafields separately?

Issue 2: Deprecation of Product Variant Fields

From the deprecation logs, Shopify is removing several product variant fields (e.g., sku, harmonizedSystemCode, inventoryManagement) in favor of using InventoryItem.

Proposed Temporary Solution

Instead of refactoring everything at once, would it be OK to stay on shopify-api-ruby 9.5.1 for now and just change how we retrieve product variant-related data?

For example, instead of accessing these fields from ProductVariant, we use InventoryItem:

ShopifyAPI::InventoryItem.find(variant.inventory_item_id)

This would allow us to avoid a full API migration all at once while still complying with Shopify’s deprecations.

Has anyone else faced a similar situation? Is this a valid approach, or should we move to GraphQL as soon as possible?

Thanks for any guidance! :folded_hands:

1 Like

Hey @Khrisna_Gunanasurya :waving_hand: - happy to see if I can help out here.

For the first issue you mentioned, this is expected behaviour. In v9.5.1, the product resource did explicitly include metafields within the Product class (more info here), but in version 13.4.0, we moved to a more structured approach where each resource class inherits from ShopifyAPI::Rest::Base (examples here).

You would need to make a separate metafields call using the metafields resource if you were going to continue using the REST API there. It’s definitely not ideal, but that would be the needed method if you were to continue using REST.

If needed in the very short term, you still technically could continue using 9.5.1 and adjust to querying on the inventory item to avoid calling the Product Variant object itself (this should stop any deprecated API call warnings as long as you aren’t calling the product variant fields directly through the Product Variant object.)

That said, our main recommendation is to migrate to using GraphQL as soon as possible, since the REST Product API is deprecated (link) and our REST API as a whole has entered Legacy Mode, meaning we won’t offer support for new functionality for it going forward and overall support will be limited.

Hope this helps - let me know if I can clarify anything on my end here! :slight_smile: