
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes, you can definitely merge documents with GROQ! For your locale merging use case, you'll want to use the object spread operator (...) combined with coalesce() to handle fallbacks.
Here's the basic pattern for merging a DE locale document onto an EN fallback:
*[_id == $documentId][0] {
...,
"title": coalesce(^[_id == $documentId + ".de"][0].title, title),
"description": coalesce(^[_id == $documentId + ".de"][0].description, description)
}But a cleaner approach is to fetch both documents and merge them in the projection:
{
"en": *[_id == "en-doc"][0],
"de": *[_id == "de-doc"][0]
} | {
...en,
...select(defined(de) => de)
}Or for a more complete solution that merges all fields automatically:
*[_id == "en-doc"][0] {
...,
...coalesce(*[_id == "de-doc"][0], {})
}The key operators you'll use:
... (spread operator): Expands objects into the surrounding projection. When you use {...a, ...b}, properties from b will override matching properties from acoalesce(): Returns the first non-null value, perfect for fallbacks. For example, coalesce(de.title, en.title) returns the DE title if it exists, otherwise the EN titleselect(): Can conditionally include values based on whether they're definedThe spread operator is documented in the GROQ operators spec, and you can read more about coalesce() in the GROQ functions documentation.
This approach keeps your query logic clean and handles missing fields gracefully by falling back to your EN values automatically.
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