How to Make Referenced Objects Inlined in a Query
pagetype that has
sections. some sections types are references, others are not, but I want all the data inlined into the result
arraythat can have
referencesand other types
then your query would be to fetch the
arraywhich would return all the different types
*[_type == 'page']
have you looked at the GROQ cheat sheet
https://www.sanity.io/docs/query-cheat-sheet
*[_type=="person"]{
name,
"relatedMovies": *[_type=='movie' && references(^._id)]{ title }
}*[_type == 'page']{
sections[]{
...,
defined(_ref) => @->
}
}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.