As of the date of the post, the Dgraph doesn't have the nested filtering feature. The only way to do it is to use the @cascade
directive. I have to create a query variable to do the next step, which is @groupby
, in my case. However, @cascade
is a post-processing step, so @groupby
completely misses filtered options.
Is there a way to construct the query to do the job?
Example: show how many companies in each sector have registered in a certain country.
type Company {
uid
sector: [string]
address: [uid]
}
type Address {
uid
country: [string]
}
-------------------------------------------
var(func: type(Company)) @cascade {
c as uid
sector
address @filter(eq(country, "$country")) {
uid
}
}
countries(func: uid(c)) @groupby(sector) {
count(uid)
}