All reverse edges of a node

Is there a query to get all reverse edges to a node without knowing the names of the reverse edges?

You can use
expand(_reverse_)

https://docs.dgraph.io/query-language/#expand-predicates

Oh, excuse me, I must have overlooked that. Thanks for your help!

Is there an alternative way to do this since expand(_reverse_) is deprecated?

yes

The simplest workaround is adding a fake edge to the Type Definition. e.g <~myChild>

The query:

See the sample dataset at the end of the comment.

{
  me(func: eq(name, "Parent")) {
    name
    CL as myChild {
      expand(_all_)
    }
  }
  reverseIt_1(func: uid(CL)) {
    uid
    expand(_all_) {
      uid 
      expand(_all_)
    }
  }
}

You can also create your own reverse mechanism with fake edges in a dummy type.

# Add this is a dummy type to your dgraph type defs
type __reverse_ {
  <~myChild>
}

I have given this name with 2 underscores cuz Dgraph will reject using the same name as the old procedure. You can give any name to this dummy type. So, in that dummy type you gonna put all possible reverse edges you would have on your DB. And then use like this

{
  var(func: eq(name, "Parent")) {
    CL as myChild
  }

  reverseIt_2(func: uid(CL)) {
    uid
    expand(__reverse_){
      uid expand(_all_)
    }
  }
}

So now you have your own mechanism of reversing edges.

Take this sample

<myChild>: [uid] @reverse .
<name>: string @index(exact) .

{
  set {
    _:Parent <name> "Parent" .
    _:Parent <myChild> _:Child .
    _:Parent <dgraph.type> "Parent" .
    
    _:Child <name> "Child" .
    _:Child <dgraph.type> "Child" .
  }
}

type Parent {
  name
  myChild
}

type Child {
  name
  <~myChild>
}