This file contains 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
package com.lavanya.aerogearlibrary.activities | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.support.v7.widget.LinearLayoutManager | |
import android.util.Log | |
import com.apollographql.apollo.ApolloCall | |
import com.apollographql.apollo.api.Response | |
import com.apollographql.apollo.exception.ApolloException | |
import com.lavanya.aerogearlibrary.* |
This file contains 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
dependencies { | |
classpath 'com.android.tools.build:gradle:3.2.1' | |
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | |
classpath 'com.apollographql.apollo:gradle-plugin:0.3.2' //Add this | |
.. | |
} |
This file contains 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
//In the project build.gradle | |
dependencies { | |
classpath 'com.android.tools.build:gradle:3.2.1' | |
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | |
classpath 'com.apollographql.apollo:gradle-plugin:0.3.2' //Add this | |
} |
This file contains 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
//In the app build.gradle | |
apply plugin: 'com.android.application' | |
//Add apollographql plugin before the kotlin plugin | |
apply plugin: 'com.apollographql.android' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-android-extensions' |
This file contains 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
... | |
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' | |
implementation 'com.apollographql.apollo:apollo-android-support:0.3.2' | |
implementation 'com.apollographql.apollo:apollo-runtime:0.3.2' | |
This file contains 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
private fun createtask(title: String, description: String) { | |
Log.e(TAG, "inside create task") | |
val client = Utils.getApolloClient(this)?.mutate( | |
CreateTask.builder().title(title).description(description).build() | |
) | |
client?.enqueue(object : ApolloCall.Callback<CreateTask.Data>() { | |
override fun onFailure(e: ApolloException) { | |
Log.e("onFailure" + "createTask", e.toString()) |
This file contains 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() |
This file contains 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
@Override | |
public <D extends Mutation.Data, T, V extends Mutation.Variables> ApolloMutationCall<T> mutate( | |
@Nonnull Mutation<D, T, V> mutation) { | |
return newCall(mutation).cacheControl(CacheControl.NETWORK_ONLY); | |
} |
This file contains 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
private fun createtask(title: String, description: String) { | |
Log.e(TAG, "inside create task") | |
val client = Utils.getApolloClient(this)?.mutate( | |
CreateTask.builder().title(title).description(description).build() | |
)?.refetchQueries(object : OperationName { | |
override fun name(): String { | |
return AllTasksQuery.OPERATION_DEFINITION | |
} |
This file contains 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
subscription SubscribeData{ | |
subscribeTasks{ | |
id | |
title | |
description | |
version | |
} | |
} |