graphql-engine
graphql-engine copied to clipboard
Issue with nested inserts
For object relationships we shouldn't be allowed to insert a nested object if its reference column is not a part of update_columns
Currently the nested object gets created but the reference column is not updated in the parent.
For example:
If I have an article with id
=1 and author_id
=1, the below request will create new author with id
=2 but the article will remain unchanged i.e. will still have author_id
=1
Request:
mutation {
insert_test_schema_article(
objects: [
{
id: 1,
title: "Article 1"
author: {
data: {
id: 2,
name: "Rikin"
}
}
}
],
on_conflict: {
constraint: article_pkey,
update_columns: []
}
) {
affected_rows
returning {
id
title
author {
id
name
}
}
}
}
Response:
{
"data": {
"insert_test_schema_article": {
"affected_rows": 2,
"returning": [
null
]
}
}
}
Author should be be inserted only if Article get updated
~~I have the exact same issue.~~
~~The expected behavior is if the parent violates the on_conflict
condition, the nested object mutation shouldn't be executed.~~
Could we raise the priority of this issue?