Hi,
Let’s say I have a type with a field that is of the same type. I would like to know the number of edges for that field/ aka number of objects the field has.
Type Store {
id: ID!
substores: [Store]
employees: [Employee]
}
In that case if I want to know how many substores a particular store has, I am trying to query it like this in dql.
query {
total(func: type(Store)) {
count(substores)
}
}
However, the result is that total
is empty. Even if there are 0 substores, it shouldn’t be empty. I am assuming it would give me 0.
"data": {
"total": []
},
But when I run the same query replacing count(substores) with count(employees), I get the expected result which includes the number of employees. I am thinking this difference could be because substores is of the same type as the parent type, but would like to know what’s the best way to get around this.