product Image Updatemutation deprecated
mutation
2024-01
Requires write
access scope. Also: The user must have a permission to update an image of a product.
Updates an image of a product. Use product
instead.
Arguments
Image to be updated.
The ID of the product on which to update the image.
Was this section helpful?
ProductImageUpdatePayload returns
The image that has been updated.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Examples
Hide code
DescriptionCopy
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-01/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();
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)
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" } }, }, });
use Shopify\Clients\Graphql; $client = new Graphql("your-development-store.myshopify.com", $accessToken); $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]);
Hide code
Input variables
Copy
{ "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" } }
Hide code
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": [] } }