
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes, absolutely! You can achieve this using the GROQ spread operator (...) to merge the lqip property into the mainImage object. Here's how:
*[_type == "post"][0] {
"mainImage": {
...mainImage,
"lqip": mainImage.asset->metadata.lqip
}
}This works by:
mainImage object in the projection...mainImage to spread all the existing properties from the original mainImage field (including _type, altText, and asset)lqip property by dereferencing the asset metadataThe result will be exactly what you're looking for:
{
"mainImage": {
"_type": "image",
"altText": "Mountains with pink sky and turquoise water",
"asset": {
"_ref": "image-db89f238f31f609d2cac163248de2105d4c1f06c-3374x2000-jpg",
"_type": "reference"
},
"lqip": "data:image/jpeg;base64,/9j/2wBDAAYEBQYFBAYGBQYHBw..."
}
}The ellipsis/spread operator (...) in GROQ is perfect for this kind of object composition where you want to keep all existing fields while adding new ones. Just note that the spread operator is always evaluated first regardless of where it appears in the projection, so any properties you define after it will override properties with the same name from the spread.
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