
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeBased on your schema, the issue is likely that you're not dereferencing the reference field when querying your data. Your schema is set up correctly, but references in Sanity store only the document ID by default - you need to explicitly tell GROQ to fetch the actual referenced document.
When you query your customTag object without dereferencing, you'll get something like:
{
"tag": "some tag",
"director": {
"_ref": "category-id-123",
"_type": "reference"
}
}To get the actual category name, you need to use the reference access operator (->) in your GROQ query:
*[_type == "yourDocumentType"] {
customTag {
tag,
director-> // This resolves the reference
}
}Or if you only want specific fields from the category:
*[_type == "yourDocumentType"] {
customTag {
tag,
director-> {
name,
title
}
}
}If this is appearing in an array, you'd do:
*[_type == "yourDocumentType"] {
customTag[] {
tag,
director->
}
}Your schema definition is fine - the -> operator is what tells GROQ to fetch the referenced category document instead of just returning the reference ID. Without it, you only get the internal _ref field, not the actual category data.
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