
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeUnfortunately, GROQ doesn't have built-in recursive dereferencing - there's no automatic way to resolve all references at any depth without manually specifying each level. The reference access operator (->) in GROQ only resolves one level at a time.
This means if you have nested references (a document references another document that references another), you need to explicitly chain the -> operator for each level:
*[_type == "article"] {
title,
author->, // Resolves 1 level
author->{ // Resolves 2 levels
name,
department->
},
author->{ // Resolves 3 levels
name,
department->{
name,
manager->
}
}
}GROQ is designed this way for good reasons:
1. Resolve what you need in your query
Be explicit about the depth you need for each use case:
*[_type == "event"] {
title,
venue->{
name,
location
},
speakers[]->{
name,
company->{ name }
}
}2. Handle additional resolution client-side
Fetch the data with some references resolved, then make additional queries for deeper data if needed. This gives you more control over loading states and performance.
3. Denormalize strategic data
For frequently accessed nested data, consider duplicating it at query time or storing computed values. You could use Sanity Functions to maintain denormalized data when documents change.
4. Use projections to limit payload size
When you do resolve references, use projections to only fetch the fields you need rather than entire documents:
*[_type == "post"] {
title,
"authorName": author->name,
"categoryTitle": category->title
}While it would be convenient to have automatic deep dereferencing, the manual approach gives you better control over query performance and helps you think intentionally about your data structure. The key is to resolve references to the depth your UI actually needs, not necessarily all possible references.
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