Skip to content

Instantly share code, notes, and snippets.

View Lavanyagaur22's full-sized avatar
🚩

Lavanya gaur Lavanyagaur22

🚩
View GitHub Profile
fun getTasks() {
noteslist.clear()
Log.e(TAG, "inside getTasks")
Log.e(TAG, " getActiveCallsCount : ${Utils.getApolloClient(this)?.activeCallsCount()}")
apolloStore = Utils.getApolloClient(this)?.apolloStore()!!
Log.e(TAG, " apolloStore : ${Utils.getApolloClient(this)?.apolloStore()}")
val client = Utils.getApolloClient(this)?.query(
fun getTasks() {
noteslist.clear()
Log.e(TAG, "inside getTasks")
Log.e(TAG, " getActiveCallsCount : ${Utils.getApolloClient(this)?.activeCallsCount()}")
apolloStore = Utils.getApolloClient(this)?.apolloStore()!!
Log.e(TAG, " apolloStore : ${Utils.getApolloClient(this)?.apolloStore()}")
val client: ApolloCall<AllTasksQuery.Data> = Utils.getApolloClient(this)?.query(
// AllTasksQuery.builder()?.build()?.let {
// Utils?.getApolloClient(this)?.query(it)
// ?.responseFetcher(ApolloResponseFetchers.CACHE_FIRST)
// ?.enqueue(object : ApolloCall.Callback<AllTasksQuery.Data>() {
// override fun onFailure(e: ApolloException) {
// e.printStackTrace()
// Log.e(TAG, "----$e ")
// }
//
// override fun onResponse(response: Response<AllTasksQuery.Data>) {
fun ApolloCall<Any>.offQueue(
apolloClient: ApolloClient,
mutation: com.apollographql.apollo.api.Mutation<Operation.Data, Operation.Data, Operation.Variables>,
callback: ApolloCall.Callback<Any>
) {
if (Offline.isNetwork()) {
this.enqueue(callback)
} else {
val operation =this.operation()
dependencies{
implementation 'org.aerogear.offix:offix:0.1.0'
...
}
<dependency>
<groupId>org.aerogear.offix</groupId>
<artifactId>offix</artifactId>
<version>0.1.0</version>
<type>pom</type>
</dependency>
//Create a mutation object
val mutation = UpdateCurrentTaskMutation.builder().id(id).title(title).version(version).build()
//Create an object of apolloCall
val client = apolloClient.mutate(mutation)?.refetchQueries(apolloQueryWatcher?.operation()?.name())
//Create a callback object of type ResponseCallback
val customCallback = object : ResponseCallback {
override fun onSuccess(response: Response<Any>) {
//Perform UI bindings accordingly.
//Create a mutation object
Mutation mutation = UpdateCurrentTaskMutation.builder().id(id).title(title).version(version).build();
//Create an object of apolloCall
ApolloMutationCall<UpdateCurrentTaskMutation.Data> client = apolloClient.mutate(mutation)
.refetchQueries(apolloQueryWatcher.operation().name());
//Create a callback object of type ResponseCallback
ResponseCallback customCallback = new ResponseCallback(){
@Override
class SampleWorker(context: Context, workParameters: WorkerParameters) : OffixWorker(context, workParameters) {
override fun doWork(): Result {
/*
getListOfMutations() returns the list of mutations stored in database in the library.
It's present in the parent class, i.e OffixWorker.
*/
val listOfMutations = getListOfMutations()
//get the mutation one by one from list
class SampleWorker extends OffixWorker{
public doWork(){
/* getListOfMutations() returns the list of mutations stored in database in the library.
It's present in the parent class, i.e OffixWorker.
*/
List<Mutation> listOfMutations=getListOfMutations();
//get the mutation one by one from list.