# Reverse Edge not Working as expected

**URL:** <https://discuss.dgraph.io/t/reverse-edge-not-working-as-expected/14320>\
**Category:** Dgraph\
**Tags:** kind:question\
**Created:** [May 26, 2021, 9:42am UTC](https://discuss.dgraph.io/t/reverse-edge-not-working-as-expected/14320 "2021-05-26T09:42:40Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [May 26, 2021, 12:26pm UTC](https://discuss.dgraph.io/t/reverse-edge-not-working-as-expected/14320/5 "2021-05-26T12:26:09Z")

</div>

What you are seeing is a data entry problem. In the GraphQL API when you add data on the predicate with an hasInverse directive on either side, the mutation rewriter in Dgraph writes this data inversely to both predicates, but when you mutate data outside of the GraphQL API endpoint such as you did with the mutate endpoint using DQL, then you bypass this control. You could have fixed this by either correcting the inverse relationships or by correctly handing inverse edges manually when using DQL.

> [@Fixing Inverse Relationships](http://discuss.hypermode.com/t/fixing-inverse-relationships/12888):
>
> I was once again needing a way to fix some relationships where the imported data using live import, was not setup correctly with inverse edges. I wrote a JavaScript snippet to quickly set my outbound and inbound type and edges and then it fixes the @hasInverse relationships correctly. I used this for a many:1 relationship, but it should also work for many:many and 1:1 relationship types without any modification needed. @gja, Do you think something like this could be added to the Slash Manageme…

Or the correct DQL initial mutation:

```auto
{
  "set": [
    {
      "uid": "0x4f51",
      "dgraph.type": "Person",
      "Person.Share": [
        {
          "uid": "0x4f4f",
          "dgraph.type": "Company",
          "Company.Shareholder": [{"uid":"0x4f51"}]
        },
        {
          "uid": "0x4f50",
          "dgraph.type": "Company",
          "Company.Shareholder": [{"uid":"0x4f51"}]
        }
      ]
    }
  ]
}

```

**Edit** : To fix syntax for Company.Shareholder edge

---

_[View the full topic](https://discuss.dgraph.io/t/reverse-edge-not-working-as-expected/14320)._
