# Upsert with @hasInverse

**URL:** <https://discuss.dgraph.io/t/upsert-with-hasinverse/16556>\
**Category:** Dgraph\
**Tags:** dgraph\
**Created:** [January 15, 2022, 5:59am UTC](https://discuss.dgraph.io/t/upsert-with-hasinverse/16556 "2022-01-15T05:59:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![porsche](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/porsche/32/9579_2.png) [@porsche](https://discuss.dgraph.io/u/porsche)\
**Post date:** [January 15, 2022, 5:59am UTC](https://discuss.dgraph.io/t/upsert-with-hasinverse/16556/1 "2022-01-15T05:59:23Z")

</div>

Create two-way edge between two nodes.

1. I was able to create both nodes fine in Ratel, but when query, edge(s) doesn’t who up in the Ratel node properties
2. Also, both nodes show up in the Ratel UI but they are not connected, does the Ratel automatically render the edge?
3. In my below query code snippet, I’m querying for both nodes, is there a way to simple way?

```auto
{
 find_conceptId(func: eq(Person.personId, "9110")) {
  uid
  Person.personId
  Person.hcs
  Person.docInstance
  Person.hasPersonalDetailChanges
}

 find_person_change(func: eq(PersonalDetail.codeId, "10")) {
  uid
  PersonalDetail.codeId
  PersonalDetail.ethnicityId
  PersonalDetail.genderId
  PersonalDetail.maritalStatusId
  PersonalDetail.raceIds
  PersonalDetail.timestamp
  PersonalDetail.person
 } 
}

```

4. Below is code upsert code snippet

```auto
upsert {
 query {
  PersonUid as var (func: eq(Person.personId, "9110"))
  PersonDetailUid as var (func: eq(PersonDetail.codeId, "10"))
 }
 mutation {
  set{
   uid(PersonUid) <Person.personId> "9110" .
   uid(PersonUid) <Person.hcs> "foo" .
   uid(PersonUid) <Person.docInstance> "7861" .
   uid(PersonUid) <Person.hasPersonalDetailChanges> uid(PersonDetailUid) .
   uid(PersonDetailUid) <PersonalDetail.person> uid(PersonUid) .
  }
 }
}

```

5. Below are my types

```auto
type PersonDetail {
  codeId: Int! @id
  timestamp: Int! @search
  ethnicityId: Int!
  genderId: Int!
  maritalStatusId: Int!
  raceIds: Int!
  person: Person
}
type Person {
  personId: String! @id
  hcs: String! @search
  docInstance: String! @search
  hasPersonalDetailChanges: [PersonalDetail] @hasInverse(field: person)
}
```

---

<div class="post-metadata">

**Author:** ![porsche](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/porsche/32/9579_2.png) [@porsche](https://discuss.dgraph.io/u/porsche)\
**Post date:** [January 15, 2022, 6:16am UTC](https://discuss.dgraph.io/t/upsert-with-hasinverse/16556/2 "2022-01-15T06:16:49Z")

</div>

- I got this working with below query snippet, Ratel automatically rendered the edge. Is there way to simple this?

```auto
{
 node(func: eq(Person.persontId, "9110")) {
 uid
 Person.personId
 person.hcs
 Person.docInstance
 Person.hasPersonalDetailChanges {
   uid
   codeId
  }
 }
}

```
