Created
June 9, 2019 03:13
-
-
Save Lavanyagaur22/a7b5001160578b2cd0e83649c440da32 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 updateTask(id: String, title: String, version: Int) { | |
Log.e(TAG, "inside update task") | |
val client: ApolloMutationCall<UpdateCurrentTask.Data>? | |
val mutation = UpdateCurrentTask.builder().id(id).title(title).version(version).build() | |
//I am trying to do something like this but not able to access it as not such method available in apollostore. | |
// Optimistic Update | |
// Network.apolloClient | |
// .apolloStore() | |
// .writeOptimisticUpdatesAndPublish(GetMyTodosQuery(), GetMyTodosQuery.Data(mutableListOf(todo)), UUID.randomUUID()).execute() | |
// getMyTodosQueryLocal() | |
client = Utils.getApolloClient(this)?.apolloStore().mutate(mutation) | |
client?.enqueue(object : ApolloCall.Callback<UpdateCurrentTask.Data>() { | |
override fun onFailure(e: ApolloException) { | |
Log.e("onFailure" + "updateTask", e.toString()) | |
} | |
override fun onResponse(response: Response<UpdateCurrentTask.Data>) { | |
val result = response.data()?.updateTask() | |
Log.e(TAG, "onResponse-UpdateTask") | |
Log.e(TAG, "${result?.id()}") | |
Log.e(TAG, "${result?.title()}") | |
Log.e(TAG, "${result?.description()}") | |
Log.e(TAG, "${result?.version()}") | |
runOnUiThread { | |
noteslist.clear() | |
getTasks() | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment