{"action":"created","comment":{"url":"https://api.github.com/repos/aerogear/offix-android/pulls/comments/302084183","pull_request_review_id":260117471,"id":302084183,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMwMjA4NDE4Mw==","diff_hunk":"@@ -0,0 +1,115 @@\n+package org.aerogear.offixsdk.worker\n+\n+import android.content.Context\n+import android.util.Log\n+import androidx.work.Worker\n+import androidx.work.WorkerParameters\n+import com.apollographql.apollo.ApolloCall\n+import com.apollographql.apollo.api.Input\n+import com.apollographql.apollo.api.Mutation\n+import com.apollographql.apollo.api.Operation\n+import com.apollographql.apollo.api.Response\n+import com.apollographql.apollo.exception.ApolloException\n+import org.aerogear.offixsdk.Application\n+import org.aerogear.offixsdk.ClientGenerator\n+\n+\n+/**\n+ * Workmanager that replicates the mutations to the server that are stored in the database.\n+ * Post firing the mutation, it is deleted from the db\n+ */\n+\n+class OfflineMutationsWorker(context: Context, workerParameters: WorkerParameters) : Worker(context, workerParameters) {\n+\n+\n+    private val getMutationDao = Application.database.mutationDao()\n+    private val getUrlDao = Application.database.urlDao()\n+\n+    val TAG = javaClass.simpleName\n+\n+    override fun doWork(): Result {\n+\n+        Log.e(TAG, \"In Worker\")\n+\n+        //get the list of mutations\n+\n+        val listOfMutations = getMutationDao.getAllMutations()\n+        Log.e(TAG, \"Size of list : ${listOfMutations.size}\")\n+\n+        //get the mutation one by one from database\n+\n+        listOfMutations.forEach { storedmutation ->\n+\n+            //Get the class name of the mutation to which it has to be mapped\n+            val responseClassName = storedmutation.responseClassName\n+\n+            val classReflected: Class<*> = Class.forName(responseClassName)\n+\n+            //Get the constructor of the class, and as apollo generated classes have only one constructor, so take the first one.\n+            val constructor = classReflected.constructors.first()","path":"offixsdk/src/main/java/org/aerogear/offixsdk/worker/OfflineMutationsWorker.kt","position":49,"original_position":49,"commit_id":"023bd517cacf4a7b5c3624cc2870dee6d39cb937","original_commit_id":"023bd517cacf4a7b5c3624cc2870dee6d39cb937","user":{"login":"wtrocki","id":981838,"node_id":"MDQ6VXNlcjk4MTgzOA==","avatar_url":"https://avatars3.githubusercontent.com/u/981838?v=4","gravatar_id":"","url":"https://api.github.com/users/wtrocki","html_url":"https://github.com/wtrocki","followers_url":"https://api.github.com/users/wtrocki/followers","following_url":"https://api.github.com/users/wtrocki/following{/other_user}","gists_url":"https://api.github.com/users/wtrocki/gists{/gist_id}","starred_url":"https://api.github.com/users/wtrocki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wtrocki/subscriptions","organizations_url":"https://api.github.com/users/wtrocki/orgs","repos_url":"https://api.github.com/users/wtrocki/repos","events_url":"https://api.github.com/users/wtrocki/events{/privacy}","received_events_url":"https://api.github.com/users/wtrocki/received_events","type":"User","site_admin":false},"body":"Uuuuu.. risky business :)","created_at":"2019-07-10T14:07:12Z","updated_at":"2019-07-10T14:07:13Z","html_url":"https://github.com/aerogear/offix-android/pull/43#discussion_r302084183","pull_request_url":"https://api.github.com/repos/aerogear/offix-android/pulls/43","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/aerogear/offix-android/pulls/comments/302084183"},"html":{"href":"https://github.com/aerogear/offix-android/pull/43#discussion_r302084183"},"pull_request":{"href":"https://api.github.com/repos/aerogear/offix-android/pulls/43"}}},"pull_request":{"url":"https://api.github.com/repos/aerogear/offix-android/pulls/43","id":296161872,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjk2MTYxODcy","html_url":"https://github.com/aerogear/offix-android/pull/43","diff_url":"https://github.com/aerogear/offix-android/pull/43.diff","patch_url":"https://github.com/aerogear/offix-android/pull/43.patch","issue_url":"https://api.github.com/repos/aerogear/offix-android/issues/43","number":43,"state":"open","locked":false,"title":"Offix Library","user":{"login":"Lavanyagaur22","id":33238323,"node_id":"MDQ6VXNlcjMzMjM4MzIz","avatar_url":"https://avatars2.githubusercontent.com/u/33238323?v=4","gravatar_id":"","url":"https://api.github.com/users/Lavanyagaur22","html_url":"https://github.com/Lavanyagaur22","followers_url":"https://api.github.com/users/Lavanyagaur22/followers","following_url":"https://api.github.com/users/Lavanyagaur22/following{/other_user}","gists_url":"https://api.github.com/users/Lavanyagaur22/gists{/gist_id}","starred_url":"https://api.github.com/users/Lavanyagaur22/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lavanyagaur22/subscriptions","organizations_url":"https://api.github.com/users/Lavanyagaur22/orgs","repos_url":"https://api.github.com/users/Lavanyagaur22/repos","events_url":"https://api.github.com/users/Lavanyagaur22/events{/privacy}","received_events_url":"https://api.github.com/users/Lavanyagaur22/received_events","type":"User","site_admin":false},"body":"### Description \r\n\r\n### Classes and their functionalities \r\n\r\n- #### ClientGenerator:\r\n Helps the user in creating an instance of apollo client. It takes in the server Url to which the request has to be sent.\r\n\r\n- #### Extension file:\r\nConsist of extension function to the apollo call's enqueue method. This takes in 2 parameters,  a mutation object, and a callback object. The network availability is checked inside it. If the network is available then `this.enqueue(callback)` is called. If the user is offline, then we extract the things from the apollocall object (which is in `this`) like operationID, valuemap etc and make an object of mutation persistence class and store in db.\r\n\r\n- #### LoggingInterceptor:\r\nWith the help of this interceptor, we can get access to the requests and responses. When the client is offline, we save the request URL in a database which we can access later while making a custom call to the server when the network connection is regained. Then we Schedule a work manager to process that request in the future.\r\n\r\n- #### OfflineMutationsWorker:\r\nWork manager that replicates the mutations to the server that are stored in the database. Also, Post firing the mutation, if we receive a response from the server in onResponse() method, then we delete that particular mutation and it's url from the DB.\r\n\r\n        \r\n\r\n\r\n\r\n","created_at":"2019-07-10T12:58:22Z","updated_at":"2019-07-10T14:07:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dffcee73fa93b2a0ce005b8be00fe3f95678c943","assignee":null,"assignees":[],"requested_reviewers":[{"login":"harshithdwivedi","id":47669588,"node_id":"MDQ6VXNlcjQ3NjY5NTg4","avatar_url":"https://avatars1.githubusercontent.com/u/47669588?v=4","gravatar_id":"","url":"https://api.github.com/users/harshithdwivedi","html_url":"https://github.com/harshithdwivedi","followers_url":"https://api.github.com/users/harshithdwivedi/followers","following_url":"https://api.github.com/users/harshithdwivedi/following{/other_user}","gists_url":"https://api.github.com/users/harshithdwivedi/gists{/gist_id}","starred_url":"https://api.github.com/users/harshithdwivedi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harshithdwivedi/subscriptions","organizations_url":"https://api.github.com/users/harshithdwivedi/orgs","repos_url":"https://api.github.com/users/harshithdwivedi/repos","events_url":"https://api.github.com/users/harshithdwivedi/events{/privacy}","received_events_url":"https://api.github.com/users/harshithdwivedi/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/aerogear/offix-android/pulls/43/commits","review_comments_url":"https://api.github.com/repos/aerogear/offix-android/pulls/43/comments","review_comment_url":"https://api.github.com/repos/aerogear/offix-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aerogear/offix-android/issues/43/comments","statuses_url":"https://api.github.com/repos/aerogear/offix-android/statuses/023bd517cacf4a7b5c3624cc2870dee6d39cb937","head":{"label":"aerogear:library1","ref":"library1","sha":"023bd517cacf4a7b5c3624cc2870dee6d39cb937","user":{"login":"aerogear","id":954205,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk1NDIwNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"repo":{"id":184272184,"node_id":"MDEwOlJlcG9zaXRvcnkxODQyNzIxODQ=","name":"offix-android","full_name":"aerogear/offix-android","private":false,"owner":{"login":"aerogear","id":954205,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk1NDIwNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/aerogear/offix-android","description":"Apollo GraphQL offline extensions for Android Platform","fork":false,"url":"https://api.github.com/repos/aerogear/offix-android","forks_url":"https://api.github.com/repos/aerogear/offix-android/forks","keys_url":"https://api.github.com/repos/aerogear/offix-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aerogear/offix-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aerogear/offix-android/teams","hooks_url":"https://api.github.com/repos/aerogear/offix-android/hooks","issue_events_url":"https://api.github.com/repos/aerogear/offix-android/issues/events{/number}","events_url":"https://api.github.com/repos/aerogear/offix-android/events","assignees_url":"https://api.github.com/repos/aerogear/offix-android/assignees{/user}","branches_url":"https://api.github.com/repos/aerogear/offix-android/branches{/branch}","tags_url":"https://api.github.com/repos/aerogear/offix-android/tags","blobs_url":"https://api.github.com/repos/aerogear/offix-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aerogear/offix-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aerogear/offix-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/aerogear/offix-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aerogear/offix-android/statuses/{sha}","languages_url":"https://api.github.com/repos/aerogear/offix-android/languages","stargazers_url":"https://api.github.com/repos/aerogear/offix-android/stargazers","contributors_url":"https://api.github.com/repos/aerogear/offix-android/contributors","subscribers_url":"https://api.github.com/repos/aerogear/offix-android/subscribers","subscription_url":"https://api.github.com/repos/aerogear/offix-android/subscription","commits_url":"https://api.github.com/repos/aerogear/offix-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/aerogear/offix-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/aerogear/offix-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/aerogear/offix-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/aerogear/offix-android/contents/{+path}","compare_url":"https://api.github.com/repos/aerogear/offix-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aerogear/offix-android/merges","archive_url":"https://api.github.com/repos/aerogear/offix-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aerogear/offix-android/downloads","issues_url":"https://api.github.com/repos/aerogear/offix-android/issues{/number}","pulls_url":"https://api.github.com/repos/aerogear/offix-android/pulls{/number}","milestones_url":"https://api.github.com/repos/aerogear/offix-android/milestones{/number}","notifications_url":"https://api.github.com/repos/aerogear/offix-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aerogear/offix-android/labels{/name}","releases_url":"https://api.github.com/repos/aerogear/offix-android/releases{/id}","deployments_url":"https://api.github.com/repos/aerogear/offix-android/deployments","created_at":"2019-04-30T13:58:58Z","updated_at":"2019-07-08T20:13:58Z","pushed_at":"2019-07-10T12:58:23Z","git_url":"git://github.com/aerogear/offix-android.git","ssh_url":"git@github.com:aerogear/offix-android.git","clone_url":"https://github.com/aerogear/offix-android.git","svn_url":"https://github.com/aerogear/offix-android","homepage":"https://aerogear.github.io/offix-android/","size":229,"stargazers_count":4,"watchers_count":4,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":8,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2,"open_issues":8,"watchers":4,"default_branch":"master"}},"base":{"label":"aerogear:master","ref":"master","sha":"4469314ea21c7aad000d8a908f60d168b3011e07","user":{"login":"aerogear","id":954205,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk1NDIwNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"repo":{"id":184272184,"node_id":"MDEwOlJlcG9zaXRvcnkxODQyNzIxODQ=","name":"offix-android","full_name":"aerogear/offix-android","private":false,"owner":{"login":"aerogear","id":954205,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk1NDIwNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/aerogear/offix-android","description":"Apollo GraphQL offline extensions for Android Platform","fork":false,"url":"https://api.github.com/repos/aerogear/offix-android","forks_url":"https://api.github.com/repos/aerogear/offix-android/forks","keys_url":"https://api.github.com/repos/aerogear/offix-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aerogear/offix-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aerogear/offix-android/teams","hooks_url":"https://api.github.com/repos/aerogear/offix-android/hooks","issue_events_url":"https://api.github.com/repos/aerogear/offix-android/issues/events{/number}","events_url":"https://api.github.com/repos/aerogear/offix-android/events","assignees_url":"https://api.github.com/repos/aerogear/offix-android/assignees{/user}","branches_url":"https://api.github.com/repos/aerogear/offix-android/branches{/branch}","tags_url":"https://api.github.com/repos/aerogear/offix-android/tags","blobs_url":"https://api.github.com/repos/aerogear/offix-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aerogear/offix-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aerogear/offix-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/aerogear/offix-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aerogear/offix-android/statuses/{sha}","languages_url":"https://api.github.com/repos/aerogear/offix-android/languages","stargazers_url":"https://api.github.com/repos/aerogear/offix-android/stargazers","contributors_url":"https://api.github.com/repos/aerogear/offix-android/contributors","subscribers_url":"https://api.github.com/repos/aerogear/offix-android/subscribers","subscription_url":"https://api.github.com/repos/aerogear/offix-android/subscription","commits_url":"https://api.github.com/repos/aerogear/offix-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/aerogear/offix-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/aerogear/offix-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/aerogear/offix-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/aerogear/offix-android/contents/{+path}","compare_url":"https://api.github.com/repos/aerogear/offix-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aerogear/offix-android/merges","archive_url":"https://api.github.com/repos/aerogear/offix-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aerogear/offix-android/downloads","issues_url":"https://api.github.com/repos/aerogear/offix-android/issues{/number}","pulls_url":"https://api.github.com/repos/aerogear/offix-android/pulls{/number}","milestones_url":"https://api.github.com/repos/aerogear/offix-android/milestones{/number}","notifications_url":"https://api.github.com/repos/aerogear/offix-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aerogear/offix-android/labels{/name}","releases_url":"https://api.github.com/repos/aerogear/offix-android/releases{/id}","deployments_url":"https://api.github.com/repos/aerogear/offix-android/deployments","created_at":"2019-04-30T13:58:58Z","updated_at":"2019-07-08T20:13:58Z","pushed_at":"2019-07-10T12:58:23Z","git_url":"git://github.com/aerogear/offix-android.git","ssh_url":"git@github.com:aerogear/offix-android.git","clone_url":"https://github.com/aerogear/offix-android.git","svn_url":"https://github.com/aerogear/offix-android","homepage":"https://aerogear.github.io/offix-android/","size":229,"stargazers_count":4,"watchers_count":4,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":8,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2,"open_issues":8,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aerogear/offix-android/pulls/43"},"html":{"href":"https://github.com/aerogear/offix-android/pull/43"},"issue":{"href":"https://api.github.com/repos/aerogear/offix-android/issues/43"},"comments":{"href":"https://api.github.com/repos/aerogear/offix-android/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/aerogear/offix-android/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/aerogear/offix-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aerogear/offix-android/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/aerogear/offix-android/statuses/023bd517cacf4a7b5c3624cc2870dee6d39cb937"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"wtrocki"}}