Hey all,
Trying to update an image with productUpdateMedia . (2024-07)
This is the mutation I have written:
mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {
productUpdateMedia(media: $media, productId: $productId) {
media {
alt
}
}
}
and passing the variables:
{
"media": [
{
"alt": "Bague Hera citrine GM",
"id": "gid://shopify/MediaImage/26278823067808"
}
],
"productId": "gid://shopify/Product/7123835814048"
}
But getting an error saying :
GraphQL Errors: {
networkStatusCode: 200,
message: "GraphQL Client: An error occurred while fetching from the API. Review 'graphQLErrors' for details.",
graphQLErrors: [
{
message: 'Variable $media of type [UpdateMediaInput!]! was provided invalid value',
locations: [Array],
extensions: [Object]
},
{
message: 'Variable $productId of type ID! was provided invalid value',
locations: [Array],
extensions: [Object]
}
],
response: Response {
[Symbol(realm)]: null,
[Symbol(state)]: {
aborted: false,
rangeRequested: false,
timingAllowPassed: true,
requestIncludesCredentials: true,
type: 'default',
status: 200,
timingInfo: [Object],
cacheState: '',
statusText: 'OK',
headersList: [HeadersList],
urlList: [Array],
body: [Object]
},
[Symbol(headers)]: HeadersList {
cookies: null,
[Symbol(headers map)]: [Map],
[Symbol(headers map sorted)]: null
}
}
}
But it works if I do the same thing with the same variables on the shopify-graphiql-app.

I don’t understand why I’m getting this error.
Can anyone help me?
Thank you!
Tony