Created
December 23, 2019 12:55
-
-
Save Lavanyagaur22/b918417032c1a8820920fbe198661460 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create a mutation object | |
val input = TaskInput.builder().title(title).version(version).description(description).status("test").build() | |
val mutation = UpdateTaskMutation.builder().id(id).input(input).build() | |
//Create an object of apolloCall | |
val mutationCall = apolloClient.mutate(mutation)?.refetchQueries(apolloQueryWatcher?.operation()?.name()) | |
//Create a callback object of type ApolloCall.Callback | |
val callback = object : ApolloCall.Callback<UpdateTaskMutation.Data>() { | |
override fun onResponse(response: Response<UpdateTaskMutation.Data>) { | |
val result = response.data()?.updateTask() | |
//In case of conflicts data returned from the server is null. | |
result?.let { | |
//Perform UI Bindings. | |
} | |
} | |
/* Called when the request could not be executed due to cancellation, a connectivity problem or timeout. | |
*/ | |
override fun onFailure(e: ApolloException) { | |
e.printStackTrace() | |
} | |
} | |
/*Call the enqueue function on ApolloClient on the apollo mutation call and pass callback to it. | |
*/ | |
mutationCall?.enqueue(callback) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment