The logic behind this query sounds quite odd but see below something that might work.
{
var(func: eq(name, 'boss')) {
Q as <~Child>
}
data(func: uid(Q)) {
uid
}
}
For more Cypher to DQL see
This in Dgraph is quite complicated.
By logic it would be something like
{
var(func: has(Child)) @filter(has(<~Child>)){
p as uid
q as Child
}
data_p(func: uid(p)) {
uid
}
data_q(func: uid(q)) {
uid
}
}
But in a Dgraph perspective this is odd and very expensive to do and you have to use reverse edges indexing. Dgraph is very different from Neo4j.