Filter logic at different query depths

This is not actually an AND.

  1. I think by AND you meant: query only the books that have a title "James" AND their author's name is "James" as well. But, this is a bit different.
  2. The query here will mean this: query only the books that have a title "James" and then for those books, query their author only if the author name is "James". i.e., even if some book’s title is “James” and it’s author’s title is “Harold”, it will still fetch the book, but not the author.

And, for the AND I explained here in 1, it can be done with @cascade on top query, like this:

{ 
  queryBook(filter: {title: {alloftext: "James"}}) @cascade { 
    id
    title
    author(filter: {name: {alloftext: "James"}}) {
      id
      name
    }
  }
}

I don’t think it could be done in a single query with GraphQL, at present. We would have to think about supporting this kind of logic in GraphQL.

With GraphQL± this is possible in the following way:

query {
	JamesAsTitle as var(func: alloftext(Book.title, "James"))
	JamesAsAuthor as var(func: type(Book)) @cascade {
		Book.author @filter(alloftext(Person.name, "James"))
	}
	JamesBooks(func: type(Book)) @filter(uid(JamesAsTitle) OR uid(JamesAsAuthor)) {
		uid
		expand(_all_) {
			expand(_all_)
		}
	}
}