Anchor to productAppendImagesproduct
productAppendImages
mutationDeprecated
Requires access scope. Also: The user must have a permission to append images to a product.
Appends images to a product. Use or
instead.
Anchor to Arguments
Arguments
- Anchor to inputinput•Product
Append requiredImages Input! Specifies the new images and the product that they're being added to.
Was this section helpful?
Anchor to ProductAppendImagesPayload returnsProductAppendImagesPayload returns
- Anchor to newImagesnew•
Images List of new images appended to the product.
- Anchor to productproduct•
The product object.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Append a non-existent image and an existing image to a product
- Append a non-existent image to a product
- Append an image to a product
- productAppendImages reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation productAppendImages($input: ProductAppendImagesInput!) {6 productAppendImages(input: $input) {7 newImages {8 id9 altText10 }11 product {12 id13 }14 userErrors {15 field16 message17 }18 }19 }`,20 {21 variables: {22 "input": {23 "id": "gid://shopify/Product/108828309",24 "images": [25 {26 "altText": "Non-existent image.",27 "src": "fake"28 },29 {30 "altText": "Existing image.",31 "src": "http://example.com/rails_logo.gif"32 }33 ]34 }35 },36 },37);3839const data = await response.json();40
mutation productAppendImages($input: ProductAppendImagesInput!) {
productAppendImages(input: $input) {
newImages {
id
altText
}
product {
id
}
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 productAppendImages($input: ProductAppendImagesInput!) { productAppendImages(input: $input) { newImages { id altText } product { id } userErrors { field message } } }",
"variables": {
"input": {
"id": "gid://shopify/Product/108828309",
"images": [
{
"altText": "Non-existent image.",
"src": "fake"
},
{
"altText": "Existing image.",
"src": "http://example.com/rails_logo.gif"
}
]
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation productAppendImages($input: ProductAppendImagesInput!) {
productAppendImages(input: $input) {
newImages {
id
altText
}
product {
id
}
userErrors {
field
message
}
}
}`,
{
variables: {
"input": {
"id": "gid://shopify/Product/108828309",
"images": [
{
"altText": "Non-existent image.",
"src": "fake"
},
{
"altText": "Existing image.",
"src": "http://example.com/rails_logo.gif"
}
]
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation productAppendImages($input: ProductAppendImagesInput!) {
productAppendImages(input: $input) {
newImages {
id
altText
}
product {
id
}
userErrors {
field
message
}
}
}`,
"variables": {
"input": {
"id": "gid://shopify/Product/108828309",
"images": [
{
"altText": "Non-existent image.",
"src": "fake"
},
{
"altText": "Existing image.",
"src": "http://example.com/rails_logo.gif"
}
]
}
},
},
});
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 productAppendImages($input: ProductAppendImagesInput!) {
productAppendImages(input: $input) {
newImages {
id
altText
}
product {
id
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"input": {
"id": "gid://shopify/Product/108828309",
"images": [{"altText"=>"Non-existent image.", "src"=>"fake"}, {"altText"=>"Existing image.", "src"=>"http://example.com/rails_logo.gif"}]
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "input": {3 "id": "gid://shopify/Product/108828309",4 "images": [5 {6 "altText": "Non-existent image.",7 "src": "fake"8 },9 {10 "altText": "Existing image.",11 "src": "http://example.com/rails_logo.gif"12 }13 ]14 }15}
Response
JSON1{2 "productAppendImages": {3 "newImages": [4 {5 "id": "gid://shopify/ProductImage/1001473906",6 "altText": "Existing image."7 }8 ],9 "product": {10 "id": "gid://shopify/Product/108828309"11 },12 "userErrors": [13 {14 "field": [15 "images",16 "0"17 ],18 "message": "Image URL is invalid"19 }20 ]21 }22}