Unable to import product using GraphQL Bulk API when adding variants array in productCreate mutation

I am importing products into Shopify using the GraphQL Admin Bulk API with productCreate.

The bulk mutation runs successfully when I do not include variants, but as soon as I add the variants array inside the product object, the product does not get imported.

My bulk mutation:

mutation {
bulkOperationRunMutation(
mutation: “”"
mutation productCreate($product: ProductCreateInput!, $media: [CreateMediaInput!]) {
productCreate(product: $product, media: $media) {
product {
id
}
userErrors {
field
message
}
}
}
“”",
stagedUploadPath: “UPLOAD_PATH”
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}

My JSONL input example:

{
“product”: {
“title”: “Amethyst - AMT 12501 (Origin - Brazil) Limited - Quality”,
“handle”: “amethyst-amt-12501-origin-brazil-limited-quality”,
“descriptionHtml”: “It is especially handpicked by our team of gem experts. It comes in deep purple color & good saturation with minimal color zoning. It has correct cut in lieu of color to make finished gem homogeneous, making it perfect gem for jewellery and for astrological benefits. Purely transparent, making light pass through unhindered, making best quality Amethyst clean & clear. It has a vitreous lustre due to color depth, correct cut and transparency.”,
“vendor”: “MyRatna”,
“productType”: “1”,
“tags”: [
“Amethyst”,
" Jamunia"
],
“status”: “ACTIVE”,
“seo”: {
“title”: “Buy Amethyst - AMT 12501 (Origin - Brazil) Limited - Quality Online | MyRatna”,
“description”: “Buy Amethyst - AMT 12501 (Origin - Brazil) Limited - Quality Online at Best Price From MyRatna. Explore 100% Natural & Lab - Certified Gemstones Online in India.”
},
“metafields”: [
{
“namespace”: “custom”,
“key”: “description_hindi”,
“type”: “multi_line_text_field”,
“value”: “\r\n\r\n\r\n\r\n\r\n\r\n\r\n”
},
{
“namespace”: “custom”,
“key”: “gram_weight”,
“type”: “number_decimal”,
“value”: “1.09”
},
{
“namespace”: “custom”,
“key”: “dimensions”,
“type”: “single_line_text_field”,
“value”: “{“length”:“13.73”,“width”:“9.91”,“height”:“6.96”}”
},
{
“namespace”: “custom”,
“key”: “origin”,
“type”: “single_line_text_field”,
“value”: “4”
},
{
“namespace”: “custom”,
“key”: “shape”,
“type”: “single_line_text_field”,
“value”: “1”
},
{
“namespace”: “custom”,
“key”: “species”,
“type”: “single_line_text_field”,
“value”: “2”
},
{
“namespace”: “custom”,
“key”: “cutting_style”,
“type”: “single_line_text_field”,
“value”: “1”
},
{
“namespace”: “custom”,
“key”: “quality”,
“type”: “single_line_text_field”,
“value”: “2”
},
{
“namespace”: “custom”,
“key”: “treatment”,
“type”: “single_line_text_field”,
“value”: “1”
},
{
“namespace”: “custom”,
“key”: “color”,
“type”: “single_line_text_field”,
“value”: “163”
},
{
“namespace”: “custom”,
“key”: “gender”,
“type”: “single_line_text_field”,
“value”: “0”
},
{
“namespace”: “custom”,
“key”: “customize”,
“type”: “number_integer”,
“value”: “1”
},
{
“namespace”: “custom”,
“key”: “new_arrivals”,
“type”: “number_integer”,
“value”: “0”
},
{
“namespace”: “custom”,
“key”: “featured”,
“type”: “number_integer”,
“value”: “1”
},
{
“namespace”: “custom”,
“key”: “exquisite_collection”,
“type”: “number_integer”,
“value”: “0”
}
],
“variants”: [
{
“price”: “1200.00”,
“compareAtPrice”: “1500.00”,
“sku”: “BS-001”,
“inventoryPolicy”: “DENY”,
“inventoryManagement”: “SHOPIFY”,
“requiresShipping”: true,
“taxable”: true,
“weight”: 1.09,
“weightUnit”: “GRAMS”
}
]
},
“media”: [
{
“mediaContentType”: “IMAGE”,
“originalSource”: “https://myratna.com/public/uploads/pimg/AMT-12501/watermark/Front.jpg”
},
{
“mediaContentType”: “IMAGE”,
“originalSource”: “https://myratna.com/public/uploads/pimg/AMT-12501/watermark/Back.jpg”
},
{
“mediaContentType”: “IMAGE”,
“originalSource”: “https://myratna.com/public/uploads/pimg/AMT-12501/watermark/Side.jpg”
},
{
“mediaContentType”: “IMAGE”,
“originalSource”: “https://myratna.com/public/uploads/pimg/AMT-12501/watermark/Hand.jpg”
},
{
“mediaContentType”: “IMAGE”,
“originalSource”: “https://myratna.com/public/uploads/pimg/AMT-12501/watermark/amt-(22)-2037186634.jpg”
}
]
}

1 Like

Hey @Khushal_Singh, productCreate only creates a single default variant in the new product model. It’s not built for importing full variant sets inline.

For a REST migration syncing from an external source, productSet may be a better mutation. It takes a complete product state in one operation, variants included, and supports bulkOperationRunMutation.

Hey @Khushal_Singh Did the above clarify this for you?