Sign up for Hasura Newsletter

Update todos - mutation

In this part of the tutorial, you will learn how to mark an existing todo as completed by using GraphQL Mutations.

Let's define a graphql query to do a mutation into todos.

mutation ($id: Int, $isCompleted: Boolean) {
update_todos (
_set: {
is_completed: $isCompleted,
},
where: {
id: {
_eq: $id
}
}
) {
returning {
id
title
is_completed
created_at
is_public
user {
name
}
}
}
}

You will also need to pass in the values for the variables.

Try this mutation in GraphiQL against the application database to see what the response looks like.

Let's now integrate this graphql mutation into our react native app.

Did you find this page helpful?
Start with GraphQL on Hasura for Free
  • ArrowBuild apps and APIs 10x faster
  • ArrowBuilt-in authorization and caching
  • Arrow8x more performant than hand-rolled APIs
Promo
footer illustration
Brand logo
© 2021 Hasura Inc. All rights reserved
Github
Titter
Discord
Facebook
Instagram
Youtube
Linkedin