Querying metaobject in a product

i’m trying to get a metaobject of a product with no success. here is how my query looks like:

query getProductByHandle {
  product(handle: "סד-לילה") {
    title
    metafield(key: "accordion_data", namespace: "custom") {
      id
      key
      namespace
      value
      type
      references(first: 10) {
        edges {
          node {
            ... on Metaobject {
              id
              type
              fields {
                key
                value
                type
              }
            }
          }
        }
      }
    }
  }
}

and here’s the response I get:

{
  "data": {
    "product": {
      "title": "סד לילה",
      "metafield": {
        "id": "gid://shopify/Metafield/29760633798909",
        "key": "accordion_data",
        "namespace": "custom",
        "value": "[\"gid://shopify/Metaobject/54758834429\",\"gid://shopify/Metaobject/54758277373\",\"gid://shopify/Metaobject/54766633213\"]",
        "type": "list.metaobject_reference",
        "references": null
      }
    }
  }
}

as can be seen in the query, it does find my data but I want the underlying fields data inside the metaobject.
how can I get the actual fields value of each metaobject?

1 Like

hi, there

try this

query getProductByHandle {
  product(handle: "xxxxx") {
    title
    metafield(key: "accordion_data", namespace: "custom") {
      id
      namespace
      key
      value
      type
      reference {
        ... on Metaobject {
          id
          type
          fields {
            key
            value
          }
        }
      }
    }
  }
}

this does not work.