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.

Querying metaobject in a product

Querying metaobject in a product

Ori
Shopify Partner
2 0 1

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?

 

Replies 2 (2)

Eric-HAN
Shopify Partner
275 30 30

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
          }
        }
      }
    }
  }
}

 

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
Ori
Shopify Partner
2 0 1

this does not work.