Images of Product/Variant: How to tell by GraphQL API that they are up to date or match mine?

Images of Product/Variant: How to tell by GraphQL API that they are up to date or match mine?

yohan-em
Shopify Partner
2 0 0

Hi,

 

I am creating an application that aggregates products from difference sources and pushes them to Shopify using the GraphQL API. I am using the ProductCreate mutation to create media with my products by using the `media` parameter. In my database, all my images are URLs with metadata such as filename, checksum (md5), content type, etc.

 

I don't see any way to create an image in Shopify and assigns a metafield like the checksum or something that would let me know if the image in Shopify matches the one I have in my database and if I should update it or not.

 

I thought maybe I could look for timestamp like createdAt or updatedAt, but even then I don't see how I could fetch that information.

 

Note: I would like to avoid storing in my database  Shopify specific informations such as IDs. This is because if I were to clear the database and setup again the same shop and data sources, I don't want the app to think it needs to re-update all existing images because the IDs are not in the database.

 

The only way I found that just "maybe" would work would be to redownload every single image one by one and redo a checksum to see if it matches mine. This would be terribly slow and again if Shopify do any kind of processing on the image (does it?) it wouldn't work either.

 

Mutation: https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/productCreate

Query: https://shopify.dev/docs/api/admin-graphql/2024-04/queries/products

Media: https://shopify.dev/docs/api/admin-graphql/2024-04/interfaces/Media 

 

Thanks in advance

Reply 1 (1)

SomeUsernameHe
Shopify Partner
515 57 109

Ooo, this might be difficult... I believe the only thing you really have with media and shopify is the name or alt text... Even when we group images together by color, we do that by adding the color as the alt text and then programmatically we only show images with alt text of "red". 

Have I helped? Consider putting coffee in my mouth!
Buy Me a Coffee