RFC: Nested Filters in GraphQL

Hi @CosmicPangolin1, Thanks for your opinion on this. Currently, aggregate queries like count are not available in filters, once we have them then it will be easy to write the filters for connected nodes as you mentioned. Currently, that can be achieved by custom DQl though. see this
Filter by counts in GraphQL

I didn’t fully get what you mean by logic stop traversal on ‘dead-end’ paths once a node fails a filter?

But I guess you mean that if there are no nested nodes and we have a filter on them then what is the behaviour of it. So for example take below DQL query. The first query just went through all nodes which have dgraph.type Author and then select those Authors from them who have post title Dgraph. But here we also got the Author who doesn’t have any posts with Author. posts equal null. So here @cascade come for our rescue, it filters out those leaf nodes and gives us the author who have posts and whose title is Dgraph.

And then in 2nd query, we use those Authors and then filters their names. So in short for the nodes which don’t have nested node for them we filter them out using @cascade at root.

query {  
     post1 as var(func:type(Author)) @cascade {
        Author.posts : Author.posts @filter(eq(Post.title, "Dgraph")){
           uid
        }
     }
queryAuthor(func: type(Author)) @filter(eq(Author.name,"Alice") and uid(post1)){
        Author.name : Author.name
        Author.posts  : Author.posts {
        Post.title : Post.title
        Post.text : Post.text 
          dgraph.uid : uid
        }
        dgraph.uid : uid
      }
    }

i hope it answers, you doubt. Thanks.