Hey @farid
That looks right to me!
I can understand that making multiple calls isn’t ideal, but I can understand on Shopify side the need to make these changes to support the extensible variant model so we can have all the variants.
There are a couple of benefits to the GraphQL calls, which I want to highlight.
- In the previous REST call it only supported one image at a time. With the GraphQL methods, you could upload multiple images etc in the same
productUpdate
call. - You can also stage your media so multiple images, videos and 3D models can be added at the same time so it would be more efficient for adding multiple media items at once.
- You can also use bulk imports with productUpdate, if you wanted affect mutliple products and media.
- If you are doing multiple media/images at once in a single GraphQL, you will be better off with the rate limit as a mutation only costs 10 points.
There is a great tutorial here around any media operations. Manage media for products
You can also combine multiple mutations into one request, it doesn’t change any rate limiting. But it might make the variant detach/attached easier for you, something like this:
mutation productVariantManageMedia(
$productId: ID!,
$detach: [ProductVariantDetachMediaInput!]!,
$append: [ProductVariantAppendMediaInput!]!) {
productVariantDetachMedia(productId: $productId, variantMedia: $variantMedia) {
userErrors {
code
field
message
}
}
productVariantAppendMedia(productId: $productId, variantMedia: $variantMedia) {
userErrors {
code
field
message
}
}
}