How to fetch meta fields referenced in the meta object?

How to fetch meta fields referenced in the meta object?

begginer1231
Shopify Partner
19 0 2
query VendorContact($handle: String!, $namespace: String!, $key: String!) {
  productByHandle(handle: $handle) {
    title
    metafield_0: metafield(namespace: $namespace, key: $key) {
      key
      namespace
      references(first: 50) {
        edges {
          node {
            ... on Metaobject {
              fields {
                key
                type
                value
              }
              definition {
                description
              }
            }
          }
        }
      }
    }
  }
}

Why reference is null?

Replies 3 (3)

oscprofessional
Shopify Partner
16343 2438 3179

Hi @begginer1231,

Check this query :

query VendorContact($handle: String!, $namespace: String!, $key: String!) {
  productByHandle(handle: $handle) {
    id
    title
    metafield(namespace: $namespace, key: $key) {
      id
      namespace
      key
      value
      references(first: 10) {
        edges {
          node {
            ... on Metaobject {
              id
              type
              handle
              definition {
                description
              }
            }
          }
        }
      }
    }
  }
}

Hope this might be helpful for you.

 

Thanks...

 

 

Hire us | Pass Core Web Vital | B2B Wholesale Experts | Claim Your Free Website Review |
Connect with Us: WhatsApp | Skype: oscprofessionals-87 | Email: pallavi@oscprofessionals.com |
Custom Shopify SolutionsPrivate Apps, Theme Customization & SEO | Digital Marketing |
OSCP Apps: Discount Suite | Wholesale App | Bundle & Upsell | Shipping Discount | and more...
begginer1231
Shopify Partner
19 0 2

Thank you. I tried with the query you suggested, but the result remains the same.

oscprofessional
Shopify Partner
16343 2438 3179

Hi @begginer1231,

The metaobject you have created please add values to it. 

Please refer screenshot because this query is working and I am getting the result. 

You can also check by directly using handle of product and metafield namespace and key.

 

oscprofessional_0-1687788998744.png

 

 

Thanks...

Hire us | Pass Core Web Vital | B2B Wholesale Experts | Claim Your Free Website Review |
Connect with Us: WhatsApp | Skype: oscprofessionals-87 | Email: pallavi@oscprofessionals.com |
Custom Shopify SolutionsPrivate Apps, Theme Customization & SEO | Digital Marketing |
OSCP Apps: Discount Suite | Wholesale App | Bundle & Upsell | Shipping Discount | and more...