Anchor to productImageUpdateproduct
productImageUpdate
mutationDeprecated
Requires access scope. Also: The user must have a permission to update an image of a product.
Updates an image of a product. Use instead.
Anchor to Arguments
Arguments
- Anchor to imageimage•Image
Input! required Image to be updated.
- Anchor to productIdproduct•
Id ID!required The ID of the product on which to update the image.
Was this section helpful?
Anchor to ProductImageUpdatePayload returnsProductImageUpdatePayload returns
- Anchor to imageimage•
The image that has been updated.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Update a product's image
- Update an image of a non-existent product
- Update the product with a non-existent image
- productImageUpdate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation productImageUpdate($productId: ID!, $image: ImageInput!) {
productImageUpdate(productId: $productId, image: $image) {
image {
id
altText
src
}
userErrors {
field
message
}
}
}`,
{
variables: {
"productId": "gid://shopify/Product/108828309",
"image": {
"id": "gid://shopify/ProductImage/183532652",
"altText": "New image description.",
"src": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1726103124"
mutation productImageUpdate($productId: ID!, $image: ImageInput!) {
productImageUpdate(productId: $productId, image: $image) {
image {
id
altText
src
}
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation productImageUpdate($productId: ID!, $image: ImageInput!) { productImageUpdate(productId: $productId, image: $image) { image { id altText src } userErrors { field message } } }",
"variables": {
"productId": "gid://shopify/Product/108828309",
"image": {
"id": "gid://shopify/ProductImage/183532652",
"altText": "New image description.",
"src": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1726103124"
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation productImageUpdate($productId: ID!, $image: ImageInput!) {
productImageUpdate(productId: $productId, image: $image) {
image {
id
altText
src
}
userErrors {
field
message
}
}
}`,
{
variables: {
"productId": "gid://shopify/Product/108828309",
"image": {
"id": "gid://shopify/ProductImage/183532652",
"altText": "New image description.",
"src": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1726103124"
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation productImageUpdate($productId: ID!, $image: ImageInput!) {
productImageUpdate(productId: $productId, image: $image) {
image {
id
altText
src
}
userErrors {
field
message
}
}
}`,
"variables": {
"productId": "gid://shopify/Product/108828309",
"image": {
"id": "gid://shopify/ProductImage/183532652",
"altText": "New image description.",
"src": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1726103124"
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation productImageUpdate($productId: ID!, $image: ImageInput!) {
productImageUpdate(productId: $productId, image: $image) {
image {
id
altText
src
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"productId": "gid://shopify/Product/108828309",
"image": {
"id": "gid://shopify/ProductImage/183532652",
"altText": "New image description.",
"src": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1726103124"
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"productId": "gid://shopify/Product/108828309",
"image": {
"id": "gid://shopify/ProductImage/183532652",
"altText": "New image description.",
"src": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1726103124"
}
}
Response
JSON{
"productImageUpdate": {
"image": {
"id": "gid://shopify/ProductImage/183532652",
"altText": "New image description.",
"src": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1726103124"
},
"userErrors": []
}
}