A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I am using bulk operation for importing CSV and creating products using Graphql
Now as suggested in "New Product Model" /variants endpoint is deprecated now
I want to make variants out of the option I have given in CSV
Now this is my bulk operation query :
<<<'QUERY' mutation ($bulkMutationKeyUpdate:String!) { bulkOperationRunMutation( mutation: "mutation call($input: ProductInput!) { productCreate(input: $input) { product {id title handle options { id name position optionValues { id name hasVariants } }variants(first: 250) { edges { node { id title price sku } } }} userErrors { message field } } }" stagedUploadPath: $bulkMutationKeyUpdate ) { bulkOperation { id url status } userErrors { message field } } } QUERY;
But it will only generate 1 variant out of the given option
I want to make variants as i have given in CSV
Solved! Go to the solution
This is an accepted solution.
After doing much R&D I found that we can achieve the same with ProductSet Mutation, we need to include graphql query of ProductSet Mutation to our BulkOperation query and assign inputs according to ProductSetInput
here is an example query for reference:
This is a bulkOperation query:
mutation bulkOperationRunMutation(
$mutation: String!
$bulkMutationKeyUpdate: String!
) {
bulkOperationRunMutation(
mutation: $mutation
stagedUploadPath: $bulkMutationKeyUpdate
) {
bulkOperation {
id
url
status
}
userErrors {
message
field
}
}
}
and this is the ProductSet Mutation query that we are passing to our bulkOperation
mutation productSet($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
title
handle
variants(first: 10) {
nodes {
sku
createdAt
updatedAt
}
}
}
userErrors {
code
field
message
}
}
}
Here if you want to know more information you can refer to this document
https://shopify.dev/docs/api/admin/migrate/new-product-model/sync-data#create-a-product-with-variant...
This is an accepted solution.
After doing much R&D I found that we can achieve the same with ProductSet Mutation, we need to include graphql query of ProductSet Mutation to our BulkOperation query and assign inputs according to ProductSetInput
here is an example query for reference:
This is a bulkOperation query:
mutation bulkOperationRunMutation(
$mutation: String!
$bulkMutationKeyUpdate: String!
) {
bulkOperationRunMutation(
mutation: $mutation
stagedUploadPath: $bulkMutationKeyUpdate
) {
bulkOperation {
id
url
status
}
userErrors {
message
field
}
}
}
and this is the ProductSet Mutation query that we are passing to our bulkOperation
mutation productSet($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
title
handle
variants(first: 10) {
nodes {
sku
createdAt
updatedAt
}
}
}
userErrors {
code
field
message
}
}
}
Here if you want to know more information you can refer to this document
https://shopify.dev/docs/api/admin/migrate/new-product-model/sync-data#create-a-product-with-variant...