A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi guys
I am trying to Create (and then update) a simple product with options and stock qty for that variant..
I try the below but I get an error: "message": "Argument 'inventoryItem' on InputObject 'ProductVariantInput' has an invalid value ([{cost: \"0.00\", tracked: true}]). Expected type 'InventoryItemInput'.",
mutation {
productCreate(input: {
handle:"aaa35daa",
bodyHtml:"ddf35dd",
descriptionHtml:"eee35e",
tags:"dddd, eee,ggg",
title:"1111Buarton",
vendor:"Burton",
options: ["Size", "Color"],
seo:{
description:"ttt",
title:"eeee"
},
variants: [
{
price:"111",
inventoryItem: [
{
cost: "0.00",
tracked: true
}]
inventoryQuantities: [
{
availableQuantity: 3,
locationId: "gid://shopify/Location/62087659605"
}]
weight:1,
sku: "4444345444",
options: ["S", "Rainbow"]
},
]
published: true
}
) {
product {
id
}
userErrors {
field
message
}
}
}
Solved! Go to the solution
This is an accepted solution.
My inventoryItem is a dictionary not a list (Python):
product = {
#...
"variants": [
#...
"inventoryItem": {"tracked": True},
"inventoryQuantities": [
{
"locationId": shopify_location_id,
"availableQuantity": quantity,
}
],
}
],
}
This is an accepted solution.
My inventoryItem is a dictionary not a list (Python):
product = {
#...
"variants": [
#...
"inventoryItem": {"tracked": True},
"inventoryQuantities": [
{
"locationId": shopify_location_id,
"availableQuantity": quantity,
}
],
}
],
}
Also maybe you are missing commad after inventoryItem as well. I'm not sure if that is just because you adjust example or not.
Thanks this got me working now..
mutation {
productCreate(input: {
title:"Test Product 2",
vendor:"AEG",
options: ["Size", "Color"],
variants: [
{
options: ["S", "Rainbow"]
inventoryItem: {tracked: true},
inventoryQuantities: [
{
availableQuantity: 3,
locationId: "gid://shopify/Location/62087659605"
}]
}
]
}
) {
product {
id
}
userErrors {
field
message
}
}
}