Understanding GROQ queries for non-Gatsby projects
6 replies
Last updated: May 10, 2020
N
Hey all π ,
Having a bit of trouble with GROQ. Normally I use GraphQL with Gatsby but trying to avoid installing a graphql client in a non-gatsby project I'm working in but I can't seem to figure out how to grok it (pun intended). I have a basic schema that looks like this:
option I would assume that it's an object that somewhere within it holds a reference, maybe? Or maybe it's not a reference in the first place?
*[_type == "landingPage"][] {
_id,
hero
}
Should give you the content of that field. If the content of hero is
{_ref: 'someDocId'}
, then the last query you tried should be correct. I suspect however that it's either just an inline object (in which case just doing the query I mentioned above should give you everything within the
hero
field), or there is a nested reference field within it, like:
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.