# Upsert with multiple UIDs

**URL:** <https://discuss.dgraph.io/t/upsert-with-multiple-uids/5223>\
**Category:** Users\
**Tags:** mutation, java-client\
**Created:** [October 12, 2019, 12:02am UTC](https://discuss.dgraph.io/t/upsert-with-multiple-uids/5223 "2019-10-12T00:02:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![amanmangal](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amanmangal/32/1249_2.png) [@amanmangal](https://discuss.dgraph.io/u/amanmangal)\
**Post date:** [October 12, 2019, 12:11pm UTC](https://discuss.dgraph.io/t/upsert-with-multiple-uids/5223/2 "2019-10-12T12:11:29Z")

</div>

I am not sure I understand all the details, but your above upsert [1] will probably look like as follows in GraphQL±. There could be minor differences due to how your data model is, so check once. You can also add conditions using Conditional Upsert [2].

```auto
upsert {
  query {
    [insert query from above]
  }

  mutation {
    set {
        uid(productsUid) <products> uid(productUid) .
        uid(productUid) <productId> "10888870" .
        uid(productUid) <options> uid(optionUid) .
        uid(optionUid) <color> "red" .
        uid(optionUid) <optionId> "16818278" .
    }
  }
}

```

[1] [Mutation - Dgraph](https://docs.dgraph.io/mutations/#upsert-block)  
[2] [Mutation - Dgraph](https://docs.dgraph.io/mutations/#conditional-upsert)

### Quick update

> I (@micheldiz) marked Aman’s answer as the correct one because it is in fact what corresponds to the requested. However, if you (future reader) want to continue reading below. Please note that other topics are covered below and this here is the right answer. The conversation below is more about troubleshooting than about the title.

---

_[View the full topic](https://discuss.dgraph.io/t/upsert-with-multiple-uids/5223)._
