A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello,
I'm trying to use bulk import to create products but Shopify returns an error for each "variants" field saying:
Field 'xxx' doesn't exist on type 'ProductVariantConnection'.
Assume the jsonl file was successfully uploaded.
This is my Query part:
mutation bulkOperationRunMutation($mutation: String!, $stagedUploadPath: String!) {
bulkOperationRunMutation(mutation: $mutation, stagedUploadPath: $stagedUploadPath) {
bulkOperation { id url status } userErrors { field message }}}
This is my Variables part:
"mutation": "mutation call($input: ProductInput!) { productCreate(input: $input) {
product { title productType vendor tags options { name } variants { price weight sku options { values } } }
userErrors { message } } }", "stagedUploadPath": "tmp/xxxxx/bulk/xxx-80f2-46ff-a5da-5aadd83/myfile.jsonl"
And this is an example jsonl file:
{ "input": { "title": "Product Title", "productType": "ANYTYPE", "vendor": "The Vendor", "tags": "dddd, eee,ggg", "options": ["Size", "Color"], "variants": [ { "price": "111", "weight": 1, "sku": "4444444", "options": ["S", "Rainbow"] }, { "price": "222", "weight": 1.3, "sku": "bbb", "options": ["S", "Blue"] }, { "price": "333", "weight": 1.3, "sku": "tttt", "options": ["M", "Pink"] } ] } }
The Response is:
{
"data": {
"bulkOperationRunMutation": {
"bulkOperation": null,
"userErrors": [
{
"message": "Invalid Bulk Mutation Field - Field 'price' doesn't exist on type 'ProductVariantConnection'"
},
{
"message": "Invalid Bulk Mutation Field - Field 'weight' doesn't exist on type 'ProductVariantConnection'"
},
{
"message": "Invalid Bulk Mutation Field - Field 'sku' doesn't exist on type 'ProductVariantConnection'"
},
{
"message": "Invalid Bulk Mutation Field - Field 'options' doesn't exist on type 'ProductVariantConnection'"
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 1000.0,
"currentlyAvailable": 990,
"restoreRate": 50.0
}
}
}
}
If I don't use the 'variants' part, the BulkOperation runs fine (obviously removing the 'variants' part in jsonl file).
What am I missing?
Hey Bro!
Have you done that ?
i need your help I am doing the same thing but i didn't able to upload JSONL file to shopify can i get some example code for it?
Thanks in advance God Bless u
Hi @syedusama0786 👋
The variables containing the mutation needs to connect to the variant edges/nodes as shown below:
mutation($input: ProductInput!) {
productCreate(input: $input) {
product {
id
variants {
edges {
node {
id
}
}
}
}
}
}
I'd recommend using our codelabs workshop here that contains example code to help streamline the bulk mutation upload process.
Hope that helps!
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
HEY BRO @ShopifyDevSup !
Thanks, bro for your time. I am very grateful.
I see codelabs workshop I done the same thing but I got an error as I adding a pic.
and the code for my bulk Mutation after uploading the JSONL File is: