Update product Images using productUpdate mutation

Topic summary

Main issue: Updating a Shopify product via the GraphQL productUpdate mutation works for text and variants, but including the images field removes existing product images.

The provided code mutation sets images with a single src URL and then queries image URLs. This behavior results in deletion of previous images rather than adding or updating them.

Constraint: The author prefers not to use productImageUpdate because their app does not store image IDs, and adopting it would require code changes to manage those IDs.

Suggestion: Use productUpdateMedia, which is designed for updating product media. However, it requires the existing mediaIds to replace or modify images.

Key terms: productUpdate updates product attributes (title, description, tags, variants). productUpdateMedia updates product media assets (images/videos) and relies on mediaIds (unique identifiers of existing media).

Status: No confirmed resolution in-thread. Action items include retrieving or storing media IDs to use productUpdateMedia, or investigating whether productUpdate’s images field supports additive updates without deletion (currently unclear).

Summarized with AI on January 8. AI used: gpt-5.

I’ve been working for a private app and i found myself needing to update the product from an external app and thus to reflect the changes of the product in the Shopify store. For this i use productUpdate mutation, this is my code;

mutation{
	productUpdate(input:{
    id: "gid://shopify/Product/7177251913918",
  	productType: ""
    descriptionHtml: ""
    tags:""
    images:{
      src: "https://image.shutterstock.com/image-photo/black-large-heavy-thick-metal-600w-1081705028.jpg"
    }
    variants: [{
      price:"20"
      compareAtPrice: "500"
      barcode:""
      inventoryManagement:SHOPIFY
    }]
    
  }
  ){
    product{
      id
      images(first: 2) {
        edges {
          node {
            url
          }
        }
      }
    
    }
  }
}

With this i am able to update the title, description of the product, the variant of the product with another price, compare_price, Sku and so on, but using images just deletes my existing images from the product.

I don’t want to use the productImageUpdate mutation because we don’t store the image id in our db and this would lead to several changes in our code. Is there something wrong with using Images field in productUpdate ?

1 Like

productUpdateMedia might do it for you … you do need the (old) mediaIds to replace … jb