sanitygroq

How to fetch multiple documents within a single query?


I want to fetch multiple pages within a single query.

My code is causing errors

const pagesQuery = groq`{
    *[_type == 'homepage']{slug},
    *[_type == 'faq']{slug},
    *[_type == 'contact']{slug}
}`

Solution

  • Something like this should work.

    *[_type in ["homepage", "faq", "contact"]]{slug}