hasura / hasura/graphql-engine
Can't do nested upsert if unique constraint
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Version Information
Server Version: [v2.0.10-cloud.1](https://cloud.hasura.io/project/1ff3f003-6a5e-4907-a304-29bac3d0132a/console/)
### Environment
Cloud
### What is the expected behaviour?
I set up a tiny hasura cloud project to show the behaviour. The name is "fair-moccasin-95". Can you access it or can I transfer ownership to someone who can have a look?


I would expect this mutation to work:
```graphql
mutation {
insert_apples(objects: [
{id: 1, apple_oranges: {
data: [{
orange_id: 2,
order: 1
},
{
orange_id: 1,
order: 2
},
],
on_conflict: {
constraint: apple_oranges_apple_id_order_key
}
}}
], on_conflict: {
constraint: apples_pkey
update_columns: [id]
}) {
affected_rows
}
}
```
but I am getting there error:
```
{
"errors": [
{
"extensions": {
"path": "$.selectionSet.insert_apples.args.objects[0].apple_oranges.data",
"code": "constraint-violation"
},
"message": "Uniqueness violation. duplicate key value violates unique constraint \"apple_oranges_pkey\""
}
]
}
```
I am expecting it to work because at the end of the mutation then the uniqueness is preserved.
Thanks a million,
Lydia
Contributor guide
Assessment
This issue has not been assessed yet.