A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
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
Point 1) I would consider a bug, the others issues at least are very unexpected for 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)
5. 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?
To learn more visit the Shopify Help Center or the Community Blog.
Hey @Richard_Monette
Thanks for digging out that information. Very interesting - good thinking.
My particular use case is
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