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.
Or the correct DQL initial mutation:
{
"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