## Run a mutation Now that the client is set up, you can run a GraphQL mutation with `Amplify.API.mutate` to create, update, and delete your data. Make sure you have the following imports at the top of your file ```swift import Amplify ``` ```swift func updateTodo() async { // Retrieve your Todo using Amplify.API.query var todo = Todo(name: "my first todo", description: "todo description") todo.description = "updated description" do { let result = try await Amplify.API.mutate(request: .update(todo)) switch result { case .success(let todo): print("Successfully created todo: \(todo)") case .failure(let error): print("Got failed result with \(error.errorDescription)") } } catch let error as APIError { print("Failed to update todo: ", error) } catch { print("Unexpected error: \(error)") } } ``` Make sure you have the following imports at the top of your file ```swift import Amplify import Combine ``` ```swift func updateTodo() -> AnyCancellable { // Retrieve your Todo using Amplify.API.query var todo = Todo(name: "my first todo", description: "todo description") todo.description = "updated description" let todoUpdated = todo let sink = Amplify.Publisher.create { try await Amplify.API.mutate(request: .update(todoUpdated)) } .sink { if case let .failure(error) = $0 { print("Got failed event with error \(error)") } } receiveValue: { result in switch result { case .success(let todo): print("Successfully created todo: \(todo)") case .failure(let error): print("Got failed result with \(error.errorDescription)") } } return sink } ``` To create data, replace the request with `.create` ```swift try await Amplify.API.mutate(request: .create(todo)) ``` To delete data, replace the request with `.delete` ```swift try await Amplify.API.mutate(request: .delete(todo)) ```