Struggling determining Media ID for a variant in webhook

I’m working on switching over by product retrieval calls from product REST API to the products GraphQL API. As part of this, I need to switch over from retrieving product images to product media. Unfortunately, the images and the media have different IDs. Notes that images are still returned by GraphQL but I believe it is deprecated and not reliably part of the API anymore. Painful, but I’m getting there.

Now I am dealing with the products/update webhooks which I use to relatively efficiently see when a product changes. In the webhooks, it contains both the image info and some media info, but I’m coming across two problems – assuming I want to rely solely on the webhook and not have to make subsequent calls. Note I’m looking at the latest and greatest (upcoming Jan 2025 release).

  1. The webhook doesn’t correlate the image and the media info. In particular, for each variant, it lists a image_id (number matching the ProductImage gid), but it doesn’t list a MediaImage or ImageSource or anything like that, so if I drop using images, then I don’t which media “thing” it is.

  2. For video Media images, the webhook doesn’t contain any video info other than the preview URL. That is, for example, what is the URL for the actual video?

Remember I’m not eager to make followup calls for everything. I’m hoping/expecting the webhook to contain everything I need about a new or updated product. It certainly used to.

Thanks.

-Jeff

1 Like

nvm on #1. I think that is solvable by looking at the back pointer info on the media object – the variant_ids, as opposed to the forward pointer on the variants object.

But I’m still stuck on #2.

Thanks.

-Jeff

Hey Jeff,

So just to confirm, you’re using the productUpdate mutation to add a video to a product, and when the products/update webhook fires it’s not showing the video URL? And this url would previously be viewable if you used REST to update a product to add a video instead - is this correct?

(and you’d like to avoid having to query the product to get this url)

Sorry, thought I had responded.

Thanks for your response, but I must not have been clear with my question.

I have an app I’m building for Shopify. Video is added to the product by the store owner, not me. Whether they are using the productUpdate mutation or the UI or a batch load, I have no idea.

The video URL is not available in the REST API because the REST API only has images, not media, but when switching to GraphQL, it is available when I retrieve products using the GraphQL API. This is good.

But when a store owner adds or modifies video for a store, I would also expect the video URL to be passed in the products/create and products/update webhooks. This is the problem – these webhooks contain the preview image for the video but not the actual video URL. My hope and expectation is that the webhooks would have all the info I need for a product without requiring me to subsequently call back into the GraphQL to get more.

Thanks.

-Jeff