Hey @flavio_ns ,
Thanks for reaching out! No worries at all—here’s how you can update a product using GraphQL in Shopify. You can break it down into three separate mutations:
- Update Product Information:
Use productUpdate to update the title, description, barcode, and SKU.
mutation UpdateProductInfo($input: ProductInput!) {
productUpdate(input: $input) {
product {
id
title
descriptionHtml
variants(first: 10) {
edges {
node {
id
sku
barcode
}
}
}
}
userErrors {
field
message
}
}
}
Variables Example:
{
"input": {
"id": "gid://shopify/Product/123456789",
"title": "New Product Title",
"descriptionHtml": "
Updated description
",
"variants": [
{
"id": "gid://shopify/ProductVariant/987654321",
"sku": "NEW-SKU",
"barcode": "1234567890123"
}
]
}
}
- Update Product Price and Cost:
mutation UpdateProductPrice($input: ProductVariantInput!) {
productVariantUpdate(input: $input) {
productVariant {
id
price
inventoryItem {
unitCost {
amount
}
}
}
userErrors {
field
message
}
}
}
Variables Example:
{
"input": {
"id": "gid://shopify/ProductVariant/987654321",
"price": "29.99",
"inventoryItem": {
"id": "gid://shopify/InventoryItem/123456789",
"unitCost": {
"amount": "15.00"
}
}
}
}
- Update Inventory Quantity:
Use inventoryAdjustQuantity to update stock levels.
mutation UpdateInventory($input: InventoryAdjustQuantityInput!) {
inventoryAdjustQuantity(input: $input) {
inventoryLevel {
id
available
}
userErrors {
field
message
}
}
}
Variables Example:
{
"input": {
"inventoryLevelId": "gid://shopify/InventoryLevel/987654321",
"availableDelta": 10
}
}
Let me know if you need any more help setting this up in GraphiQL!
If I was able to help you, please don’t forget to Like and mark it as the Solution!
If you’re looking for expert help with customization or coding, I’d be delighted to support you. Please don’t hesitate to reach out via the email in my signature below—I’m here to help bring your vision to life!
Best Regard,
Rajat