How can I iterate through a repeatable group field?

Hi, I'm trying to query a repeatable group field in my project. I've made a "Single" type page with a repeatable group called FAQ. I'm trying to query it on multiple pages. Appreciate any help!

    {faqs.nodes.map(faq => (
      <>
      <h1>{faq.data.group.question.text}</h1>
      </>
    ))}

export const pageQuery = graphql`
  query PageBySlug($uid: String!) {
    page: prismicPage(uid: { eq: $uid }) {
      id
      uid
      data {
        page_description {
          text
        }
        page_title {
          text
        }
      }
    }
    events: allPrismicEvent {
      nodes {
        data {
          title {
            text
          }
          text {
            text
          }
        }
        uid
        id
      }
    }
    faqs: allPrismicFaq {
      nodes {
        data {
          title {
            text
          }
          group {
            question {
              text
            }
            answer {
              text
            }
          }
        }
        id
        uid
      }
    }
  }
`

for gastby-prismic-source plugin - i figured it out. if you want to map out repeatable group fields from a single custom type, you need to query from prismicFaq instead of allPrismicFaq

{faqs.data.group.map(faq => (
      <>
      <h3>{faq.question.text}</h3>
      <p>{faq.answer.text}</p>
      </>
    ))}

faqs: prismicFaq {
  data {
    group {
      answer {
        text
      }
      question {
        text
      }
    }
  }
}
1 Like

Hello Andrew,

Thanks for posting us.

I apologise that we never came back to you. Is this query now working for you?

Thanks,
Priyanka