Good day to you all.
The need was to find a way to use an expression like productVariantCreate through bulkOperationRunMutation.
However, productVariantCreate is not available to be used through bulkOperationRunMutation.
The only one that kinda resembled what was needed and that happens to be supported by bulkOperationRunMutation is productVariantUpdate, which I have already been able to use successfully with no further complication.
Right now, productVariantsBulkCreate is being tested, and I will update with the mutation and the variables structures once the goal is achieved.
That’d be all for the moment.
I share this “draft” because there is almost no clear pathway to get to the information that is needed to achieve this kind of procedure, and maybe a slight glimpse on the matter could help a lot to others.

1 Like
Hi, good day!
So, bulkOperationRunMutation can be used fulfilling 2 parameters:
-
- The mutation and
-
- The key to an uploaded file
In this sense, productVariantsBulkCreate can be used fulfilling 2 parameters as well:
-
- The product ID, you know, the product that will house the variants that will be created, and
-
- A JSON object that contains data for the variants creation, different parameters such as id, inventoryItem, options, sku, price, etc.
I haven’t been able to find a way to make productVariantsBulkCreate to work with variables that can be processed through the parsing of an uploaded file.
It’s supposed that bulk operations have been enabled in order to handle large volumes of data, to avoid costly and repetitive mutations; based on what I’ve stated regarding productVariantsBulkCreate, it seems to me that the only solution that has been publicly distributed to the community implies the need to perform a mutation per product.
Have you any idea on how it would be possible to create, not update, but create variants within specific products using the bulk importing workflow that is advertised to promote bulk operations?
If anybody knows about this, please, let us know.
In the meantime I’ll be working on this and updating here if I find anything else.
2 Likes
Hello ,
I am new to GraphQL and new to Shopify.
I am able to create bulk products using the example on shopify GraphQL Reference.
I am wondering if I can have the mutation to create Variants in Bulk for existing Product.
Here is what I have tried and I will appreciate if you can point out what is wrong with this.
mutation {
bulkOperationRunMutation(
mutation: "mutation call($productId: ID!, $variants: ProductVariantBulkInput!) {productVariantsBulkCreate(productId: $productId, variants: $variants) { product {id title variants(first: 10) {edges {node {id title sku barcode inventoryQuantity inventoryItem {id} }}}} userErrors { message field } } }",
stagedUploadPath: "s3-file-uploaded.jsonl") {
bulkOperation {
id
url
status
}
userErrors {
message
field
}
}
}
Also for Reference , here is how my input file s3-file-uploaded.jsonl looks like,
{"variants":[{"options":["Used - Acceptable"],"inventoryQuantities":[{"availableQuantity":1,"locationId":"gid:\/\/shopify\/Location\/93306519836"}],"price":"91.77","barcode":"0143136224","weight":1.9,"weightUnit":"POUNDS","sku":"0143136224-500-5","inventoryItem":{"tracked":true}}],"productId":8917150957852}