# How to create backlinks in DQL for graphql

**URL:** <https://discuss.dgraph.io/t/how-to-create-backlinks-in-dql-for-graphql/9413>\
**Category:** Dgraph\
**Tags:** graphql, help-wanted\
**Created:** [August 13, 2020, 3:23pm UTC](https://discuss.dgraph.io/t/how-to-create-backlinks-in-dql-for-graphql/9413 "2020-08-13T15:23:46Z")\
**Posts on this page:** 1\
**Page:** 1

<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:** [August 13, 2020, 3:23pm UTC](https://discuss.dgraph.io/t/how-to-create-backlinks-in-dql-for-graphql/9413/1 "2020-08-13T15:23:46Z")

</div>

Schema that links Events to Contacts:

```auto
type Contact {
  id: ID
  hasEvents: [Event] @hasInverse(field: at)
  ...
}

type Event {
  id: ID
  at: Contact @hasInverse(field: hasEvents)
  ...
} 

```

I imported the data with:

```auto
{
  set {
    _:contact_1 <dgraph.type> "Contact" .
    ...
    _:event_1 <dgraph.type> "Event" .
    _:event_1 <Event.at> _:contact_1 .
    ...
  }
}

```

As you see, I forgot to add the reverse of `_:contact_1 <Contact.hasEvents> _:event_1 .` In my import script. Is there a way to fix this after the fact and somehow create the reverse for every `Event.at` edge and map it to `Contact.hasEvents` edge?

I was thinking of an upsert like:

```auto
upsert {
  query {
    event as var(func: has(Event.at)){
      Event.at {
        contact as uid
      }
    }
  }
  mutate {
    set {
      contact <Contact.hasEvent> event .
    }
  }
}

```

But this will set every event for every contact, and does not produce the desired results.

Is this possible without [FOREACH func in DQL (loops in Bulk Upsert) VOTE! - #4 by MichelDiz](http://discuss.hypermode.com/t/foreach-func-in-graphql-loops-in-bulk-upsert/5533/4)
