
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGood news! You don't need to list every field when dereferencing references. The -> operator by itself automatically fetches all fields from the referenced document.
Your simplified query can just be:
export const categoryBySlug = groq`*[_type == "category" && slug.current == $slug]{
title,
"slug": slug.current,
description,
"excerpt": array::join(string::split((pt::text(description)), "")[0..160], "") + "...",
"content": content[]->
}[0]`The reference access operator (->) automatically resolves the reference and returns all fields from the referenced documents. When you add new fields to your "service" or "post" documents, they'll automatically appear in your query results without any changes needed.
What if I want to be selective?
If you later decide you do want to limit which fields are returned (for performance or clarity), you can add a projection:
"content": content[]->{
title,
description,
website
}But unless you have a specific reason to limit fields, just using content[]-> gives you everything and is the most maintainable approach.
A note about the ellipsis operator (...)
You might see the ellipsis operator (...) used in GROQ projections, but it serves a different purpose. It's used to include all fields from the current document being iterated, not for dereferencing. For example, *[_type == 'movie']{...} returns all fields from movie documents. It's not needed when dereferencing references—the -> operator already handles that for you.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store