How to delete an object by pressing a button with onClick via mutation

How to delete an object by pressing a button with onClick via mutation


0

There is code with GraphQL in bff and in the application part. This function is described as follows:

shema.js:

type Mutation {
  deleteCart(id: Int): [Cart]
}

index.js:

deleteCart: (_, args) => {
  carts = carts.filter((c) => c.id !== args.id);
  return carts;
}

As declared in query:

export const CART_ITEMS = gql`
mutation DeleteCart ($id: Int) {
  deleteCart(id: $id) {
    id, title, text, size, price, image
  }
}`

It’s also not entirely clear how to implement triggering via button clicks onClick.

When I try to do this inside the GraphQL graphical interface, I get an error:

Assignment to constant variable

New contributor

Vasilii is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


Load 6 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *