For example I have a schema:
type Author {
name: String
books: [Book] @hasInverse(field: author)
}
type Book {
author: Author @hasInverse(field: books)
genre: String @search(by: [hash])
}
Is it possible to make nested filter? Something like that:
{
queryAuthor(filter: { books: { genre: { eq: "detective" }}}) {
name
books {
name
genre
}
}
}
Here I want to get all the authors who wrote books in the genre of detective (and their books)
Hi, thanks for looking at our GraphQL features.
Filtering a result based on some deeper feature in the graph is a really powerful thing. Problem is the level of nesting needed is unbounded, so that ends up making a really big schema and really deep queries.
In our extended GraphQL± query language, you can do queries like this with query variables (https://docs.dgraph.io/query-language/#query-variables) or the handy uid_in function (https://docs.dgraph.io/query-language/#uid-in). We are planing on adding those sorts of feature in a GraphQL compliant way.
In the current GraphQL implementation, you’ll need to issue multiple queries where you restrict by ids to create the same effect.
Hey @poketulhu,
Adding onto what @michaelcomptonsaid, you can also check out the section on cascade in this blog https://blog.dgraph.io/post/tutorial-8-getting-started/ .
Cascade in Dgraph’s GraphQL± query language helps you filter the top layer results based on the filter in the deeper parts of the query.