Hi Sanity Team! I need some help with a GROQ query…Let’s say I have a list component that displays articles and has an array of tags to switch between articles that are associated with that tag.
Would it be possible to get all the articles that are associated with each tag, in one query?
Something like:
*[_type == “list_component” && _id=“dsf”] {tags} {
//“tagName”: *[_type == “article” && references(tagId)]
}
I’d like to end with a result that looks something like this:
{
Tag1: [Array of articles associated with this tag],
Tag2: [Array of articles associated with this tag],
…
TagN: [Array of articles associated with this tag]
}
Currently, I have one query to get the tags from my list component. Then I have another query that gets the articles that reference each tag, but I would like to have it all in one query.
Thanks in advance! and sorry if my question isn’t very clear
😅
Oct 21, 2022, 5:57 PM