How to reference a field in a Groq query in another part of the query without using a variable passed.
Last updated: Sep 21, 2023
I’m looking to reference a field in a groq query in another part of the query, but without using a variable passed. I’ve got a query which gets articles based on slug, one of the fields it pulls is the ‘categoryTitle’. Now i also have a ‘relatedArticles’ query in the same query which pulls articles based if its not the slug of the hero article, ideally i want to be able to use the categoryTitle from the hero post to filter the ‘related articles’ (see screenshot below) to only get articles that have the same categoryTitle - any idea of how to do this?
Hey Parker, thanks a lot for your help - i had originally used the parent selector for a join, and hadnt got it working. However after looking at your solution, i was able to adjust it to this to get it to work