Hi
Adding a metafield to a product image does not work (using 2023-04).
The mutation returns a “User Error” message: “invalid id”
(Strangely, creating a metafield definitions with “ownerType”: “PRODUCTIMAGE” yields no error.)
To reproduce:
(Replace gid://shopify/ProductImage/XXXXXXXXXX with an actual product image gid)
mutation MetafieldsSet($metafields: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafields) {
metafields {
id
}
userErrors {
field
message
}
}
}
VARIABLES:
{
"metafields": [
{
"key": "test",
"namespace": "test",
"ownerId": "gid://shopify/ProductImage/XXXXXXXXXX",
"value": "test",
"type": "single_line_text_field"
}
]
}
RESPONSE:
{
"data": {
"metafieldsSet": null
},
"errors": [
{
"message": "invalid id",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"metafieldsSet"
]
}
],
}
Hi @_Dominik 
Thanks for flagging this! We are working on a fix, and will update you here as soon as it ships.
Sweet, thanks @ShopifyDevSup
while I have your attention, and I am digging deep into the image APIs, there are a couple more inconsistencies I found
- webhooks for the PRODUCTS_UPDATE topic fire as expected when an image is edited via the built-in image editor in the admin UI (e.g. cropping an image) in which case the image gid stays the same while update_at is changed. But they don’t fire in the same way when an image is altered via the productimageupdate mutation.
- The rest API includes timestamps (created_at and updated_at) for product image, but the graphql api does not
- The REST api for retrieving products does not include metafields, even if including “metafields” in the “fields” parameter.
- But payloads of webhooks for the PRODUCTS_UPDATE topic contains both, the image metafields (when setting correct WebhookSubscriptionInput.metafieldNamespaces) and the image timestamps.
Point 1) I would consider a bug, the others issues at least are very unexpectedfor me. Point 4) then saves the day, please don’t alter that behaviour 
Thanks for listening.
Cheers
EDIT: (One more find from before regarding metafields and webhooks)
- When listing namespaces to be included via WebhookSubscriptionInput.metafieldNamespaces, the Api layer’s resolving of app reserved namespace, like $app:namespace, does not seem to kick in. Typing it out, like {app}–{your-app-id}–{some-namespace}, works
Hey Dominik, regarding your first point, the built-in editor uses the https://shopify.dev/docs/api/admin-graphql/2022-07/mutations/productUpdateMedia mutation. If you prefer the behaviour where the PRODUCTS_UPDATE webhook fires as a result of the update, would using that mutation be an option for you?
Hey @Richard_Monette
Thanks for digging out that information. Very interesting - good thinking.
My particular use case is
- The app needs to be able to react to any product image changes – no matter how that change was initiated.
- The app is not going to initiate updates itself.
So I am trying to cover all possible ways that an product image can be altered and making sure that we can react to that without having to bulk crawl the whole product catalog 
Hope that makes sense. Any ideas how to solve this? The only way I see is that I need to have confidence that webhooks covers all cases…
Thank you very much for your help!
Dominik