Take the following schema / data:
<link2>: [uid] .
<link>: [uid] .
type C {
uid
}
type B {
link2
}
type A {
link
}
<_:a0> <dgraph.type> "A" .
<_:a1> <dgraph.type> "A" .
<_:b0> <dgraph.type> "B" .
<_:b1> <dgraph.type> "B" .
<_:b2> <dgraph.type> "B" .
<_:b3> <dgraph.type> "B" .
<_:b4> <dgraph.type> "B" .
<_:b5> <dgraph.type> "B" .
<_:b6> <dgraph.type> "B" .
<_:b7> <dgraph.type> "B" .
<_:b8> <dgraph.type> "B" .
<_:c0> <dgraph.type> "C" .
<_:c1> <dgraph.type> "C" .
<_:c2> <dgraph.type> "C" .
<_:a0> <link> <_:b0> .
<_:a0> <link> <_:b1> .
<_:a0> <link> <_:b2> .
<_:a0> <link> <_:b3> .
<_:a1> <link> <_:b4> .
<_:a1> <link> <_:b5> .
<_:a1> <link> <_:b6> .
<_:a1> <link> <_:b7> .
<_:a1> <link> <_:b8> .
<_:b0> <link2> <_:c0> .
<_:b1> <link2> <_:c0> .
<_:b2> <link2> <_:c1> .
<_:b3> <link2> <_:c1> .
<_:b4> <link2> <_:c1> .
<_:b5> <link2> <_:c2> .
<_:b6> <link2> <_:c2> .
<_:b7> <link2> <_:c2> .
<_:b8> <link2> <_:c2> .
I can get A > C directly with a @normalized query.
{
A(func: type(A)) {
uid
C : link @normalize {
link2 {
uid : uid
}
}
}
}
But what I would like, is to get a count of distinct Cs connected to each A, as in:
{
"data": {
"A": [
{
"uid": "0x80a1b1",
"count": "2"
},
{
"uid": "0x80c8c1",
"count": "2"
}
]
}
}
I’ve tried a series of different groupby’s, but to no avail. Is it possible without mutating the data and creating an edge from A to C directly?
Thank you!