This is a groq query I use to find all authors that are not referenced by any category. In my case category has a list of authors (that is basically what defines a cateogry).
'_type == "author" && !(_id in path("drafts.*")) && count(*[ _type == "category" && references(^._id)]) == 0' I use this query in my deskStructure to catch any authors that haven't been assigned to categories.