I am new to graphql hasura and i'm having this issue how to update multiple rows in one table, because usually i update only one row per table.
i want to update multiple rows in a dynamic way
I have for example existing rows data.
id: 1, name: 'rosie', age: 12
id: 2, name: 'jane', age: 20
id: 3, name: 'rafaela', age: 25
and I want to edit the 2 rows only.
id: 1, name: 'rosie update', age: 12
id: 2, name: 'jane update', age: 21
i have an array of users. it can be 1 or more than 1 users that will be updated.
const users = [
{id: 1, name: 'rosie update', age: 12}.
{id: 2, name: 'jane update', age: 21}
];
mutation update_article {
update_user(
where: {id: {_eq: users[0].id}},
_set: {
name: users[0].name,
age: users[0].age
}
) {
affected_rows
}
}
expected output should be:
want to have mutation code in dynamic way not static.
id: 1, name: 'rosie update', age: 12
id: 2, name: 'jane update', age: 21
id: 3, name: 'rafaela', age: 25