I want to retrieve multiple metafields from a Blog/Article

rattlesnakeMT
Shopify Partner
25 2 1

I created some Metafields for Blog Posts and have them populated. I'm building a Hydrogen Shopify storefront and using GraphQL to fetch that blog/article data. But I can't seem to figure out how to get all the metafields. Seems like 'metafield' and 'metafields' only return a single field based on key and namespace. Is there a way to more than one?

 

query Blog($language: LanguageCode, $blogHandle: String!, $first: Int, $last: Int, $startCursor: String, $endCursor: String) @inContext(language: $language) {
  blog(handle: $blogHandle) {
    title
    seo {
      title
      description
    }
    articles(
      first: $first
      last: $last
      before: $startCursor
      after: $endCursor
      reverse: true
    ) {
      nodes {
        ...ArticleItem
        metafields(identifiers: {namespace: "custom", key: "misc_content_long_text_1"}) {
          value
          references {
            edges {
              node
            }
          }
        }
      }
      pageInfo {
        hasPreviousPage
        hasNextPage
        hasNextPage
        endCursor
        startCursor
      }
    }
  }
}

fragment ArticleItem on Article {
  author: authorV2 {
    name
  }
  contentHtml
  handle
  id
  image {
    id
    altText
    url
    width
    height
  }
  publishedAt
  title
  blog {
    handle
  }
}

 

 

My metafields include:

misc_content_long_text_1

misc_content_long_text_2

misc_content_long_text_3

misc_text_field_1

misc_text_field_2

misc_text_field_3

misc_text_field_4

misc_text_field_5

 

I'm hoping I don't have to call multiple queries to fetch those. TIA

 

 

 

 

Hank D
Replies 0 (0)