mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
add replace nested objects example to update docs (#2962)
This commit is contained in:
parent
094bbc8760
commit
46ac68952f
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user