
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeNo worries, this is a common question when you're getting started with GROQ! The good news is your query is actually really close – you just need to simplify it a bit.
You can absolutely include the .asset->url reference directly in your projection. Here's how to write it:
const query = groq`*[_type == "siteSettings"]{ "image": gigs_image.asset->url }`;
const result = await client.fetch(query).catch(error => console.error(error));Or if you want the first (and likely only) siteSettings document:
const query = groq`*[_type == "siteSettings"][0]{ "image": gigs_image.asset->url }`;
const result = await client.fetch(query).catch(error => console.error(error));What's happening here:
The -> operator in GROQ is called the dereference operator, and it follows references to other documents. When you have an image field in Sanity, it stores a reference to an asset document. Using gigs_image.asset->url tells GROQ to:
gigs_image fieldasset to the actual image asset documenturl field from that assetA few tips:
"image" create an alias for the field in your result (so you get { image: "https://..." } instead of { url: "https://..." })gigs_image.asset-> without the .url at the end*[_type == "siteSettings"] returns an array, adding [0] gets you the first document directly, which is cleaner if you only have one settings documentHope this helps! GROQ's reference following with -> is super powerful once you get the hang of it.
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