Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How can I set a product metafield to be a file reference (image) using graphQL?

How can I set a product metafield to be a file reference (image) using graphQL?

den232
Shopify Partner
220 8 57

How to get from here to there?

 

I have a few images that I need to attach to a product but not be visible as product image.   I would like to use a metafield with the type file_reference.  I see how to read it out, but not how to set it.  As I understand, I need the mediaImage id to set its value.   I can do a staged upload but how do I get from there to a gid for the image?

 

It should be going into something like this ...

 

Thanks! and best regards jb

 

metafield(namespace: "xxx", key: "yyy") {
   reference {
     ... on MediaImage {
       image {
       originalSrc
       }
     }
  }
}

 

 

Replies 0 (0)