I’m migrating some existing GraphQL code that is no longer compatible with the new 2024-04 API.
My requirements are:
Create a product with a single/default variant, and leave it with status Draft
The variant must have a SKU
The variant quantity must be tracked in inventory.
The variant must have qty 1 in a location that is not enabled by default when the product is created
Publish the product to two Sales Channels: Online Store and Point of Sale
Before, I was able to achieve what I needed in 2 GraphQL API Calls:
productCreate: I created the product with the inventoryItem > tracked: True flag, SKU, and inventory Quantities for a non default Inventory Location.
publishablePublish: Published the product to the Online Store and Point of Sale sales channels. Later when the product status is changed to Active, these Sales Channels are already enabled.
With the 2024-04 API Changes, it seems that I need to make 5 API Calls:
productCreate: I can no longer specify any variant information, so the product cannot be marked as tracked by inventory or with a SKU.
inventoryActivate: For the default product variant InventoryItem, I activate an Inventory Location that is not enabled by default.
productVariantUpdate: For the default product variant, I add the SKU, taxable: True, inventoryItem > tracked: true. Here, if I add inventoryQuantities as part of the mutation input, it doesn’t modify the available quantity or come back with an error. The rest of the data is updated Ok. Is this a bug?
inventorySetOnHandQuantities: For the default product variant InventoryItem, I set the quantity to 1.
publishablePublish: I publish the product to the Online Store and Point of Sale sales channels.
Am I approaching this the correct way? Or would there be a better way to achieve my requirements with the new API?
5 API calls seems an exaggerate number to add one product with the desired properties. Also, there’s a higher probability of API transient errors to break the expected functionality (e.g.: Adding the product, but not assigning inventory quantities).
keep getting post Response Logging: {“errors”:[{“message”:“Variable $productId of type ID! was provided invalid value”,“locations”:[{“line”:2,“column”:68}],“extensions”:{“value”:null,“problems”:[{“path”:,“explanation”:“Expected value to not be null”}]}},{“message”:“Variable $variants of type [ProductVariantsBulkInput!]! was provided invalid value”,“locations”:[{“line”:2,“column”:85}],“extensions”:{“value”:null,“problems”:[{“path”:,“explanation”:“Expected value to not be null”}]}}]} bookdelivered.myshopify.com error. Please help