Reverse edges

Edges are directional. A query can’t traverse an edge in reverse.

There are two choices to query in both directions

  • Add the reverse edge to the schema and add all the reverse edge data.

  • Tell Dgraph to always store the reverse edge using the @reverse keyword in the schema.

Run the schema mutation and Dgraph will compute all the reverse edges. The reverse edge of an_edge is ~an_edge.

In terms of data modeling, some reverse edges always make sense, such as friend. Others, such as boss_of, are sometimes, but not always bidirectional.

Endpoint: /alter
Response