πŸ‘€ See Sanity in action: Watch product demo now β†’

Ok I figured it out... holy crap GROQ is amazing. I still love GQL for what it is, but I think GROQ is the best thing since bread, sliced or otherwise.

1 replies
Last updated: Dec 20, 2020
Ok I figured it out... holy crap GROQ is amazing. I still love GQL for what it is, but I think GROQ is the best thing since bread, sliced or otherwise.
Dec 20, 2020, 6:32 PM
For anyone who's interested, here's the query:
export const getCats = `// groq
    *[_type == "category"]{
        _id, name, slug,
        "products": *[_type == "product" && references(^._id)]{
             _id, name, slug
        } | order(_createdAt desc)[0..4]
    }
`
Dec 20, 2020, 6:48 PM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Categorized in