Hello Team,
We are in the process of migrating our public app from REST APIs to the new GraphQL product APIs, and we need some guidance on the best approach.
Previously, we used the REST endpoint:
POST /products.json
This allowed us to create a product along with all its variants in a single request, and it worked seamlessly.
With GraphQL, we’re using the productCreate mutation for creating products and productVariantsBulkCreate for creating variants. However, we’re encountering issues:
- The productCreate mutation is creating only a single variant (without pricing, inventory, etc).
Here’s the solution we are considering:
- Use the productCreate mutation to create the product with the first variant.
- Use the productVariantsBulkCreate mutation to add the remaining variants.
- Update the first variant with pricing, inventory, and other details.
Does this approach align with best practices? Or is there a more efficient way to handle this migration?
I’ve attached an example product with its variants for reference.
Thank you in advance for your help and insights!
Thanks,
Durgesh