with the productSet mutation not able to update existing image on existing varinat

Topic summary

A user is experiencing an issue with the productSet mutation when attempting to update images on existing product variants.

Problem behavior:

  • Variant-level images are being removed instead of updated on the first mutation call
  • Product-level images update correctly
  • Running the identical mutation a second time successfully updates the variant images
  • No errors are returned in the API response

Technical context:
The mutation uses the file object with originalSource and contentType: "IMAGE" to update variant images. Each variant includes an ID (for existing variants) along with the new image data.

Current status:
The issue remains unresolved. The workaround of running the mutation twice is not ideal for production use. This appears to be a potential bug in the GraphQL Product API’s handling of variant image updates.

Summarized with AI on November 4. AI used: claude-sonnet-4-5-20250929.

below are the query and variables that are being used.
Use case: Varinats on this product already have an image trying to update the image with the below mutation.
There are no errors in the response but the variant level image is not updated with the latest value instead they are being removed. The product-level image is properly updated.
If we send the same request again without any changes, variants are updated with the latest images

mutation createEntireProduct($input: ProductSetInput!, $synchronous: Boolean!) {
    productSet(synchronous: $synchronous, input: $input) {
        product {
            id
            title
            description
            options(first: 5) {
                name
                position
                optionValues {
                    name
                }
            }
            variants(first: 5) {
                nodes {
                    id
                    price
                    compareAtPrice
                    selectedOptions {
                        name
                        optionValue {
                            id
                            name
                        }
                    }
                    taxable
                    taxCode
                    barcode
                    inventoryPolicy
                    metafields(first: 5) {
                        nodes {
                            key
                            value
                            type
                            namespace
                        }
                    }
                }
            }
        }
        userErrors {
            field
            message
        }
    }
}
{
    
    "synchronous": true,
    "input": {
      "title": "image-test-matrix22",
      "id": "gid://shopify/Product/8894817075501",
      "variants": [
        {
          "barcode": "image-test-matrix",
          "price": 90,
          "sku": "image-test-matrix22-B-M",
          "inventoryPolicy": "DENY",
          "file": {
            "originalSource": "https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg",
            "contentType": "IMAGE"
          },
          "optionValues": [
            {
              "name": "Blue",
              "optionName": "color"
            },
            {
              "name": "Medium",
              "optionName": "size"
            }
          ]
        },
        {
          "id": "gid://shopify/ProductVariant/47312528441645",
          "barcode": "image-test-matrix",
          "price": 90,
          "sku": "image-test-matrix21-Bl-M",
          "inventoryPolicy": "DENY",
          "file": {
            "originalSource": "https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg",
            "contentType": "IMAGE"
          },
          "optionValues": [
            {
              "name": "Black",
              "optionName": "color"
            },
            {
              "name": "Medium",
              "optionName": "size"
            }
          ]
        },
        {
          "id": "gid://shopify/ProductVariant/47312528474413",
          "barcode": "image-test-matrix",
          "price": 90,
          "sku": "image-test-matrix21-G-M",
          "inventoryPolicy": "DENY",
          "file": {
            "originalSource": "https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg",
            "contentType": "IMAGE"
          },
          "optionValues": [
            {
              "name": "Green",
              "optionName": "color"
            },
            {
              "name": "Medium",
              "optionName": "size"
            }
          ]
        },
        {
          "id": "gid://shopify/ProductVariant/47312559866157",
          "barcode": "image-test-matrix",
          "price": 90,
          "sku": "image-test-matrix21-Bl-S",
          "inventoryPolicy": "DENY",
          "file": {
            "originalSource": "https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg",
            "contentType": "IMAGE"
          },
          "optionValues": [
            {
              "name": "Black",
              "optionName": "color"
            },
            {
              "name": "Small",
              "optionName": "size"
            }
          ]
        },
        {
          "id": "gid://shopify/ProductVariant/47312559898925",
          "barcode": "image-test-matrix",
          "price": 90,
          "sku": "image-test-matrix21-Bl-L",
          "inventoryPolicy": "DENY",
          "file": {
            "originalSource": "https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg",
            "contentType": "IMAGE"
          },
          "optionValues": [
            {
              "name": "Black",
              "optionName": "color"
            },
            {
              "name": "Large",
              "optionName": "size"
            }
          ]
        },
        {
          "id": "gid://shopify/ProductVariant/47312559800621",
          "barcode": "image-test-matrix",
          "price": 90,
          "sku": "image-test-matrix21-B-S",
          "inventoryPolicy": "DENY",
          "file": {
            "originalSource": "https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg",
            "contentType": "IMAGE"
          },
          "optionValues": [
            {
              "name": "Blue",
              "optionName": "color"
            },
            {
              "name": "Small",
              "optionName": "size"
            }
          ]
        },
        {
          "id": "gid://shopify/ProductVariant/47312559833389",
          "barcode": "image-test-matrix",
          "price": 90,
          "sku": "image-test-matrix21-B-L",
          "inventoryPolicy": "DENY",
          "file": {
            "originalSource": "https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg",
            "contentType": "IMAGE"
          },
          "optionValues": [
            {
              "name": "Blue",
              "optionName": "color"
            },
            {
              "name": "Large",
              "optionName": "size"
            }
          ]
        },
        {
          "id": "gid://shopify/ProductVariant/47312559931693",
          "barcode": "image-test-matrix",
          "price": 90,
          "sku": "image-test-matrix21-G-S",
          "inventoryPolicy": "DENY",
          "file": {
            "originalSource": "https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg",
            "contentType": "IMAGE"
          },
          "optionValues": [
            {
              "name": "Green",
              "optionName": "color"
            },
            {
              "name": "Small",
              "optionName": "size"
            }
          ]
        },
        {
          "id": "gid://shopify/ProductVariant/47312559964461",
          "barcode": "image-test-matrix",
          "price": 90,
          "sku": "image-test-matrix21-G-L",
          "inventoryPolicy": "DENY",
          "file": {
            "originalSource": "https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg",
            "contentType": "IMAGE"
          },
          "optionValues": [
            {
              "name": "Green",
              "optionName": "color"
            },
            {
              "name": "Large",
              "optionName": "size"
            }
          ]
        }
      ],
      "productOptions": [
        {
          "name": "color",
          "values": [
            {
              "name": "Blue"
            },
            {
              "name": "Black"
            },
            {
              "name": "Green"
            }
          ],
          "position": 1
        },
        {
          "name": "size",
          "values": [
            {
              "name": "Medium"
            },
            {
              "name": "Small"
            },
            {
              "name": "Large"
            }
          ],
          "position": 1
        }
      ],
      "files": [
        {
          "originalSource": "https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg",
          "contentType": "IMAGE"
        }
      ]
    }
}
2 Likes