-
Notifications
You must be signed in to change notification settings - Fork 51
Mutation
Siddhant Srivastav edited this page Jan 25, 2019
·
1 revision
GraphQL mutations are used to modify data on the server (i.e. write, update or delete data).
Mutations for the entire codebase resides in the file /app/shared/mutations/ts
The syntax for writing mutation is
mutation <MUTATION_NAME>($objects: [<TABLE_NAME>_<TYPE_OF_OPERATION>_input!]!) {
insert_user(objects: $objects) {
affected_rows
returning {
<COLUMN_NAMES>
}
}
}
Insert Mutation
mutation insert_user($objects: [user_insert_input!]!) {
insert_user(objects: $objects) {
affected_rows
returning {
id
}
}
}
Update Mutation
mutation update_user($objects: user_set_input!) {
update_user(
where: {id: {_eq: 5}}
_set: $objects) {
affected_rows
returning {
id
}
}
}