add replace nested objects example to update docs (#2962)

This commit is contained in:
Marion Schleifer 2019-12-10 11:37:20 +01:00 committed by Rikin Kachhia
parent 094bbc8760
commit 46ac68952f

View File

@ -230,7 +230,6 @@ evaluates to ``true`` for all objects.
}
}
Increment **int** columns
-------------------------
You can increment an ``int`` column with a given value using the ``_inc`` operator.
@ -497,3 +496,54 @@ The input value should be a ``String Array``.
}
}
Replace all nested array objects of an object
---------------------------------------------
In order to replace all existing nested array objects of an object, currently it's required to use two mutations:
one to delete all the existing objects and one to add a list of new nested objects.
**Example:** Replace all articles of an author with a new list:
.. graphiql::
:view_only:
:query:
mutation updateAuthorArticles($author_id: Int!) {
delete_articles(
where: {author_id: {_eq: $author_id}}
) {
affected_rows
}
insert_articles(
objects: [
{
author_id: $author_id,
title: "title",
content: "some content"
},
{
author_id: $author_id,
title: "another title",
content: "some other content"
}
]
) {
affected_rows
}
}
:response:
{
"data": {
"delete_article_tags": {
"affected_rows": 3
},
"insert_article_tags": {
"affected_rows": 2
}
}
}
:variables:
{
"author_id": 21
}