productVariantDetachMedia id issue

Solved

productVariantDetachMedia id issue

HaydnVirtue
Shopify Partner
2 1 0

Hi, 

 

I have the following mutation and variable. I have carefully checked the ids and they are those returned from a product query. I am using the GraphiQL installed on my dev store to try this.

 

I get this error but can't figure out why:

"errors": [{"message": "invalid id",
"locations": [{"line": 4,"column": 3}],
"path": ["productVariantDetachMedia"]

The mutation is:

mutation productVariantDetachMedia(
$variantMedia: [ProductVariantDetachMediaInput!]!
) {
productVariantDetachMedia(productId: "gid://shopify/Product/6117569069212", variantMedia:$variantMedia)

{product {id}
 productVariants {id}
userErrors {field

message}

}

}

and the variable:

{"variantMedia": [
{"variantId": "gid://shopify/ProductVariant/41707314643100",
"mediaIds": ["gid://shopify/ProductImage/33883924463772"]
}]
}

 

If anyone can see an issue or suggest another way to try this, I'd be really grateful!

 

Thanks,

Haydn

Accepted Solution (1)

HaydnVirtue
Shopify Partner
2 1 0

This is an accepted solution.

In case it helps anyone, I have resolved the issue.

I was using the variant image field to get the id:  image {id}

This needs to be the variant media field: 

media(first: 1) {edges {node {... on MediaImage {id}}}}

View solution in original post

Reply 1 (1)

HaydnVirtue
Shopify Partner
2 1 0

This is an accepted solution.

In case it helps anyone, I have resolved the issue.

I was using the variant image field to get the id:  image {id}

This needs to be the variant media field: 

media(first: 1) {edges {node {... on MediaImage {id}}}}