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
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.",
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-07/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
JSON{
"input": {
"id": "gid://shopify/Product/108828309",
"images": [
{
"altText": "Non-existent image.",
"src": "fake"
},
{
"altText": "Existing image.",
"src": "http://example.com/rails_logo.gif"
}
]
}
}
Response
JSON{
"productAppendImages": {
"newImages": [
{
"id": "gid://shopify/ProductImage/1001473906",
"altText": "Existing image."
}
],
"product": {
"id": "gid://shopify/Product/108828309"
},
"userErrors": [
{
"field": [
"images",
"0"
],
"message": "Image URL is invalid"
}
]
}
}