Mutation and update cache
Open Todo/TodoVC.swift
and add the following function to delete all the completed todos from the cloud.
// Remove all completed Todos from cloudprivate func removeAllCompletedTodosCloud(){apollo.perform(mutation: ClearCompletedMutation()) { (result, error) inguard let data = result?.data else { return }if data.deleteTodos?.affectedRows == self.filteredTodos.filter({$0.isCompleted}).count {self.todos = self.todos.filter({!$0.isCompleted})self.filteredTodos = self.filteredTodos.filter({!$0.isCompleted})self.removeTodosMutationLocal(id: -1)DispatchQueue.main.async {self.toggleCompleteAction()}}}}
And finally update the removeAllCompleted
function as below
@IBAction func removeAllCompleted(_ sender: Any) {// Remove all completed todos on click of Remove Completed Button+ removeAllCompletedTodosCloud()}
That's a wrap of the todo app.
Did you find this page helpful?
Start with GraphQL on Hasura for Free
Build apps and APIs 10x faster
Built-in authorization and caching
8x more performant than hand-rolled APIs
![Promo](/learn/graphql/ios/static/hasura-free-ff60e409244e0ea12b5a3045d1a9096b.png)
![footer illustration](https://graphql-engine-cdn.hasura.io/learn-hasura/assets/footer-img.png)