Created
July 12, 2019 13:52
-
-
Save Lavanyagaur22/b0a144a1e86ab08f8c4f7c656bf9ddab 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 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() | |
val operationID = operation.operationId() | |
val queryDoc = operation.queryDocument() | |
val operationName = operation.name() | |
val valuemap = operation.variables().valueMap() | |
val jsonObject = JSONObject(valuemap) | |
val responseClassName = mutation.javaClass.name | |
val mutationObj = Mutation(operationID, queryDoc, operationName, jsonObject, responseClassName) | |
libDb?.mutationDao()?.insertMutation(mutationObj) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment