Mutation and update cache

Open Todo/TodoVC.swift and add the following function to delete all the completed todos from the cloud.

githubTodo/TodoVC.swift
// Remove all completed Todos from cloud
private func removeAllCompletedTodosCloud(){
apollo.perform(mutation: ClearCompletedMutation()) { (result, error) in
guard 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 basic todo app.