Created
December 23, 2019 12:53
-
-
Save Lavanyagaur22/ad39b136ec0b9bb89faab264e6bdd8ac 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
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