Display all the tags (and their category) of a single recipe.
When I inspect the document of the recipe, I only get _key and _ref.
What did I do wrong?
_keyis to give each array item a unique identifier and the
_refis the ID of the referenced document. To show these references in your React app, you will need to use the dereferencing operator
->to join them in your query.
For example, if you're using GROQ:
*[_type == "recipe"]{
...,
thetags[]->{
...,
category->
}
}Was this answer helpful?
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.