I’m attempting to migrate to GQL from the Rest API and I’m finding it impossible to update the alt tag of images while maintaining the same image.
What I’m expecting is that when I make a call to the articleUpdate mutation with just altText it would return the entire image property of the article with the new altText in it but the same url as before, however this is not the case as seen in these screenshots.
Further, I’ve tried passing in the existing url as the url property next to the altText property and it mutates the image and adds a UUID to the filename, which is not good for my purposes. How can this be accomplished without changing the filename?
See below. First screenshot illustrates that an image already exists. 2nd screenshot is the result of trying to update only the alt tag. Image and alt tag are completely removed in both the response as well as the Admin UI.
Hi Benofficial,
Digging into this - thanks for sharing screenshots and descriping your current flow. If you update alt tags using REST, do the image URLs remain the same?
Thanks for your response.
Yes, this is actually a key part of the app I’m working on and I’ve been able to use the REST API to edit alt tags for Products, Collections and Articles for quite some time now without having to include anything about the actual image. I’m banking on GQL being able to accomplish the same thing.
Sorry to jump in here, but I joined the forums today to report this exact problem. I can’t figure out a mutation to update the image alt tags for a product image. I know the gid, but I keep getting a file not found error. It works with the rest API.
Here’s some mutations I’ve tried
mutation = """
mutation FileUpdate($input: [FileUpdateInput!]!) {
fileUpdate(files: $input) {
userErrors {
code
field
message
}
files {
alt
}
}
}
"""
variables = {
"input": [
{
"id": gid://shopify/ProductImage/123456789,
"alt": new_alt_text
}
]
}
mutation = """
mutation FileUpdate($input: [FileUpdateInput!]!) {
fileUpdate(files: $input) {
userErrors {
code
field
message
}
files {
... on MediaImage {
id
alt
}
}
}
}
"""
variables = {
"input": [
{
"id": f"gid://shopify/ProductImage/123456789",
"alt": new_alt_text
}
]
}
That’s actually a different issue. You need to use this endpoint to map ProductImage ids to MediaImage ids. fileUpdate will 404 if you don’t provide the new id.
The issue I’m reporting in this thread has to do with Article and Collection images as well as MediaImages.
Hi again @Benofficial
Our team have confirmed this is a bug and are investigating how to resolve this.
Thank you for getting back to me. Would a fix also include the collectionUpdate and fileUpdate mutations as well?
Hi @Liam-Shopify wondering if you have an ETA on when this bug might be addressed as well as if it will also fix the collectionUpdate and fileUpdate mutations which appear to have the same issue?