Remove todos - mutation

In this part of the tutorial, you will learn how to remove existing todos by using GraphQL Mutations.

Let's define a graphql query to do a mutation into todos. In the file src/graphql-operations/index.ts, add the following:

export const DELETE_TODOS_BY_PK = gql`
mutation delete_todos_by_pk($id: Int!) {
delete_todos_by_pk(id: $id) {
id
title
is_completed
created_at
is_public
}
}
`

Try this mutation in GraphiQL against the application database to see what the response looks like. You will also need to pass in the values for the variables.

Let's now integrate this graphql mutation into our vue 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
© 2024 Hasura Inc. All rights reserved
Github
Titter
Discord
Facebook
Instagram
Youtube
Linkedin
graphql-handbook