Accessing MediaImages and metafields

GrantDB
Shopify Partner
73 3 14

I am looking at using the New MediaImge (replacing image).  I can add the image no problem but I want to add metafields to the image.

 

I can sue metafieldsSet to add metadata

 

{
  "metafields": [
    {
      "key": "zexample",
      "namespace": "hcp",
      "ownerId": "gid://shopify/MediaImage/25277232775256",
      "type": "string",
      "value": "my value"
    },
    {
      "key": "example",
      "namespace": "hc-defined",
      "ownerId": "gid://shopify/Product/7359008473176",
      "type": "string",
      "value": "my value"
    }
  ]
}
But I don't seem to be able to see that.
 
 
query productByHandle ($handle: String!){
    productByHandle(handle: $handle){
        id
        title
        handle
        media(first:10){
            edges {
                node{
                    id
                    alt
                    status
                    mediaContentType
                    preview {
                        image {
                            altText
                            id
                            metafield(key: "zexample",namespace: "hcp") {
                                namespace
                                key
                                value
                                id
                            }
                        metafields(first: 20) {
                            edges {
                                node {
                                    id
                                    key
                                    value
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        images(first:10){
            edges {
                node {
                    src
                    id
                    altText
                    src
                    metafields(first: 10) {
                        edges {
                            node {
                                id
                                key
                                value
                                namespace
                            }
                        }
                    }
                }
            }
        }
    }
}
 
I see metadata on an image but not on the media
 
                    {
                        "node": {
                            "id": "gid://shopify/MediaImage/25277232775256",
                            "alt": "hello grant.",
                            "status": "READY",
                            "mediaContentType": "IMAGE",
                            "preview": {
                                "image": {
                                    "altText": "hello grant.",
                                    "id": "gid://shopify/ImageSource/25283307602008",
                                    "metafield": null,
                                    "metafields": {
                                        "edges": []
                                    }
                                }
                            }
                        }
                    }

Can anyone tell me what I am missing?

 

Thanks

Replies 0 (0)