What does an ellipsis (...) mean in a GROQ query?
Yes, that's GROQ (Graph-Relational Object Queries), Sanity's query language! The ... is called the ellipsis operator (or spread operator), and it's used in projections to include all fields from a document.
What it does
The ... expands to include all fields from the current document or object you're querying. Think of it like JavaScript's spread operator, but for GROQ queries.
In your examples:
*[_id == "${document}"] {
...,
}This returns all fields from the matching document. The ... says "give me everything that's in this document."
export const pageQuery = `
...,
content {
...,
main {
...,
modules[] {
...,
${moduleQuery}
}
}
}
`;Here you're using ... at multiple levels to include all fields at each level, plus you're explicitly expanding nested objects like content, main, and modules[].
Why use it?
The ellipsis operator is super useful when you want:
- All existing fields plus some custom ones
- To avoid listing every single field manually
- To override specific fields while keeping everything else
Important quirk: Order matters!
The ... is always evaluated first, regardless of where you put it. This means if you write:
{
title: "Override",
...
}The ... is evaluated first, then your title override applies. But to avoid confusion and unintended overrides, it's best practice to put ... at the beginning:
{
...,
title: "Override"
}This makes it clear you're starting with all fields, then modifying specific ones. Check out the official GROQ pipeline components documentation for more details on how projections work!
Show original thread21 replies
Sanity – Build the way you think, not the way your CMS thinks
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.