Skip to content

Instantly share code, notes, and snippets.

@Lavanyagaur22
Created December 23, 2019 12:53
Show Gist options
  • Save Lavanyagaur22/ad39b136ec0b9bb89faab264e6bdd8ac to your computer and use it in GitHub Desktop.
Save Lavanyagaur22/ad39b136ec0b9bb89faab264e6bdd8ac to your computer and use it in GitHub Desktop.
fun createTask(title: String, description: String, version: Int) {
val input =
TaskInput.builder().title(title).description(description).version(version).status("test")
.build()
val mutation = CreateTaskMutation.builder().input(input).build()
val mutationCall = Utils.getApolloClient(this)?.mutate(
mutation
)?.refetchQueries(apolloQueryWatcher?.operation()?.name())
val callback = object : ApolloCall.Callback<CreateTaskMutation.Data>() {
override fun onFailure(e: ApolloException) {
Log.e("onFailure() updateTask", "${mutation.variables().valueMap()}")
e.printStackTrace()
}
override fun onResponse(response: Response<CreateTaskMutation.Data>) {
val result = response.data()?.createTask()
//Logging the result
result?.let {
Log.e(TAG, "onResponse-CreateTask- $it")
}
}
}
mutationCall?.enqueue(callback)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment