{"action":"created","comment":{"url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/comments/175828499","pull_request_review_id":105423063,"id":175828499,"diff_hunk":"@@ -42,111 +45,100 @@ export default function fetchGitHubRepo(\n     throw new Error(`Invalid token: ${token}`);\n   }\n \n-  const query = `query FetchData($repoOwner: String!, $repoName: String!) {\n-    repository(owner: $repoOwner, name: $repoName) {\n-      issues(first: 100) {\n-        pageInfo {\n-          hasNextPage\n-        }\n-        nodes {\n-          id\n-          title\n-          body\n-          number\n-          author {\n-            ...whoami\n-          }\n-          comments(first: 20) {\n-            pageInfo {\n-              hasNextPage\n-            }\n-            nodes {\n-              id\n-              author {\n-                ...whoami\n-              }\n-              body\n-              url\n-            }\n-          }\n-        }\n-      }\n-      pullRequests(first: 100) {\n-        pageInfo {\n-          hasNextPage\n-        }\n-        nodes {\n-          id\n-          title\n-          body\n-          number\n-          author {\n-            ...whoami\n-          }\n-          comments(first: 20) {\n-            pageInfo {\n-              hasNextPage\n-            }\n-            nodes {\n-              id\n-              author {\n-                ...whoami\n-              }\n-              body\n-              url\n-            }\n-          }\n-          reviews(first: 10) {\n-            pageInfo {\n-              hasNextPage\n-            }\n-            nodes {\n-              id\n-              body\n-              author {\n-                ...whoami\n-              }\n-              state\n-              comments(first: 10) {\n-                pageInfo {\n-                  hasNextPage\n-                }\n-                nodes {\n-                  id\n-                  body\n-                  author {\n-                    ...whoami\n-                  }\n-                }\n-              }\n-            }\n-          }\n-        }\n-      }\n-    }\n-  }\n-\n-  fragment whoami on Actor {\n-    __typename\n-    login\n-    ... on User {\n-      id\n-    }\n-    ... on Organization {\n-      id\n-    }\n-    ... on Bot {\n-      id\n-    }\n-  }\n-  `;\n+  const query = GraphQLQueries.stringify.body(\n+    createQuery(),\n+    GraphQLQueries.inlineLayout()\n+  );\n   const variables = {repoOwner, repoName};\n   const payload = {query, variables};\n   return postQuery(payload, token);\n }\n \n const GITHUB_GRAPHQL_SERVER = \"https://api.github.com/graphql\";\n \n+function createQuery(): Body {\n+  const b = GraphQLQueries.build;\n+  const makePageInfo = () => b.field(\"pageInfo\", {}, [b.field(\"hasNextPage\")]);\n+  const makeAuthor = () => b.field(\"author\", {}, [b.fragmentSpread(\"whoami\")]);\n+  const body: Body = [\n+    b.query(\n+      \"FetchData\",\n+      [b.param(\"repoOwner\", \"String!\"), b.param(\"repoName\", \"String!\")],\n+      [\n+        b.field(\n+          \"repository\",\n+          {owner: b.variable(\"repoOwner\"), name: b.variable(\"repoName\")},\n+          [\n+            b.field(\"issues\", {first: b.literal(100)}, [","path":"src/plugins/github/fetchGitHubRepo.js","position":136,"original_position":136,"commit_id":"d3d9b42bf39e0890fee8ac1781a9c97e1c9d1852","original_commit_id":"d3d9b42bf39e0890fee8ac1781a9c97e1c9d1852","user":{"login":"dandelionmane","id":1400023,"avatar_url":"https://avatars2.githubusercontent.com/u/1400023?v=4","gravatar_id":"","url":"https://api.github.com/users/dandelionmane","html_url":"https://github.com/dandelionmane","followers_url":"https://api.github.com/users/dandelionmane/followers","following_url":"https://api.github.com/users/dandelionmane/following{/other_user}","gists_url":"https://api.github.com/users/dandelionmane/gists{/gist_id}","starred_url":"https://api.github.com/users/dandelionmane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dandelionmane/subscriptions","organizations_url":"https://api.github.com/users/dandelionmane/orgs","repos_url":"https://api.github.com/users/dandelionmane/repos","events_url":"https://api.github.com/users/dandelionmane/events{/privacy}","received_events_url":"https://api.github.com/users/dandelionmane/received_events","type":"User","site_admin":false},"body":"Maybe factor all the first (N) arguments into constants?","created_at":"2018-03-20T16:12:54Z","updated_at":"2018-03-20T16:13:04Z","html_url":"https://github.com/sourcecred/sourcecred/pull/94#discussion_r175828499","pull_request_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/94","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/comments/175828499"},"html":{"href":"https://github.com/sourcecred/sourcecred/pull/94#discussion_r175828499"},"pull_request":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/94"}}},"pull_request":{"url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/94","id":176223611,"html_url":"https://github.com/sourcecred/sourcecred/pull/94","diff_url":"https://github.com/sourcecred/sourcecred/pull/94.diff","patch_url":"https://github.com/sourcecred/sourcecred/pull/94.patch","issue_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/94","number":94,"state":"open","locked":false,"title":"Use structured GraphQL query API in GitHub fetcher","user":{"login":"wchargin","id":4317806,"avatar_url":"https://avatars3.githubusercontent.com/u/4317806?v=4","gravatar_id":"","url":"https://api.github.com/users/wchargin","html_url":"https://github.com/wchargin","followers_url":"https://api.github.com/users/wchargin/followers","following_url":"https://api.github.com/users/wchargin/following{/other_user}","gists_url":"https://api.github.com/users/wchargin/gists{/gist_id}","starred_url":"https://api.github.com/users/wchargin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wchargin/subscriptions","organizations_url":"https://api.github.com/users/wchargin/orgs","repos_url":"https://api.github.com/users/wchargin/repos","events_url":"https://api.github.com/users/wchargin/events{/privacy}","received_events_url":"https://api.github.com/users/wchargin/received_events","type":"User","site_admin":false},"body":"Summary:\r\nIn addition to being nicer on the eyes, this enables the query to be\r\nstatically analyzed (e.g., by an auto-pagination API) and used by other\r\nmodules.\r\n\r\nTest Plan:\r\nManually running\r\n```shell\r\n$ yarn backend\r\n$ GITHUB_TOKEN=\"<your_token>\" src/plugins/github/fetchGitHubRepoTest.sh\r\n```\r\nsucceeds.\r\n\r\nwchargin-branch: use-structured-graphql-queries","created_at":"2018-03-20T15:12:37Z","updated_at":"2018-03-20T16:13:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f50c1f661886e345fd8ccd0efa721267bc17321f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/94/commits","review_comments_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/94/comments","review_comment_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/94/comments","statuses_url":"https://api.github.com/repos/sourcecred/sourcecred/statuses/d3d9b42bf39e0890fee8ac1781a9c97e1c9d1852","head":{"label":"sourcecred:wchargin-use-structured-graphql-queries","ref":"wchargin-use-structured-graphql-queries","sha":"d3d9b42bf39e0890fee8ac1781a9c97e1c9d1852","user":{"login":"sourcecred","id":35711667,"avatar_url":"https://avatars1.githubusercontent.com/u/35711667?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcecred","html_url":"https://github.com/sourcecred","followers_url":"https://api.github.com/users/sourcecred/followers","following_url":"https://api.github.com/users/sourcecred/following{/other_user}","gists_url":"https://api.github.com/users/sourcecred/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcecred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcecred/subscriptions","organizations_url":"https://api.github.com/users/sourcecred/orgs","repos_url":"https://api.github.com/users/sourcecred/repos","events_url":"https://api.github.com/users/sourcecred/events{/privacy}","received_events_url":"https://api.github.com/users/sourcecred/received_events","type":"Organization","site_admin":false},"repo":{"id":120145570,"name":"sourcecred","full_name":"sourcecred/sourcecred","owner":{"login":"sourcecred","id":35711667,"avatar_url":"https://avatars1.githubusercontent.com/u/35711667?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcecred","html_url":"https://github.com/sourcecred","followers_url":"https://api.github.com/users/sourcecred/followers","following_url":"https://api.github.com/users/sourcecred/following{/other_user}","gists_url":"https://api.github.com/users/sourcecred/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcecred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcecred/subscriptions","organizations_url":"https://api.github.com/users/sourcecred/orgs","repos_url":"https://api.github.com/users/sourcecred/repos","events_url":"https://api.github.com/users/sourcecred/events{/privacy}","received_events_url":"https://api.github.com/users/sourcecred/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sourcecred/sourcecred","description":"credit attribution for open-source projects. like street cred, for source code.","fork":false,"url":"https://api.github.com/repos/sourcecred/sourcecred","forks_url":"https://api.github.com/repos/sourcecred/sourcecred/forks","keys_url":"https://api.github.com/repos/sourcecred/sourcecred/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sourcecred/sourcecred/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sourcecred/sourcecred/teams","hooks_url":"https://api.github.com/repos/sourcecred/sourcecred/hooks","issue_events_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/events{/number}","events_url":"https://api.github.com/repos/sourcecred/sourcecred/events","assignees_url":"https://api.github.com/repos/sourcecred/sourcecred/assignees{/user}","branches_url":"https://api.github.com/repos/sourcecred/sourcecred/branches{/branch}","tags_url":"https://api.github.com/repos/sourcecred/sourcecred/tags","blobs_url":"https://api.github.com/repos/sourcecred/sourcecred/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sourcecred/sourcecred/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sourcecred/sourcecred/git/refs{/sha}","trees_url":"https://api.github.com/repos/sourcecred/sourcecred/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sourcecred/sourcecred/statuses/{sha}","languages_url":"https://api.github.com/repos/sourcecred/sourcecred/languages","stargazers_url":"https://api.github.com/repos/sourcecred/sourcecred/stargazers","contributors_url":"https://api.github.com/repos/sourcecred/sourcecred/contributors","subscribers_url":"https://api.github.com/repos/sourcecred/sourcecred/subscribers","subscription_url":"https://api.github.com/repos/sourcecred/sourcecred/subscription","commits_url":"https://api.github.com/repos/sourcecred/sourcecred/commits{/sha}","git_commits_url":"https://api.github.com/repos/sourcecred/sourcecred/git/commits{/sha}","comments_url":"https://api.github.com/repos/sourcecred/sourcecred/comments{/number}","issue_comment_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/comments{/number}","contents_url":"https://api.github.com/repos/sourcecred/sourcecred/contents/{+path}","compare_url":"https://api.github.com/repos/sourcecred/sourcecred/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sourcecred/sourcecred/merges","archive_url":"https://api.github.com/repos/sourcecred/sourcecred/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sourcecred/sourcecred/downloads","issues_url":"https://api.github.com/repos/sourcecred/sourcecred/issues{/number}","pulls_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls{/number}","milestones_url":"https://api.github.com/repos/sourcecred/sourcecred/milestones{/number}","notifications_url":"https://api.github.com/repos/sourcecred/sourcecred/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sourcecred/sourcecred/labels{/name}","releases_url":"https://api.github.com/repos/sourcecred/sourcecred/releases{/id}","deployments_url":"https://api.github.com/repos/sourcecred/sourcecred/deployments","created_at":"2018-02-04T01:32:53Z","updated_at":"2018-03-20T03:06:56Z","pushed_at":"2018-03-20T15:12:38Z","git_url":"git://github.com/sourcecred/sourcecred.git","ssh_url":"git@github.com:sourcecred/sourcecred.git","clone_url":"https://github.com/sourcecred/sourcecred.git","svn_url":"https://github.com/sourcecred/sourcecred","homepage":"","size":497,"stargazers_count":13,"watchers_count":13,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":16,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":16,"watchers":13,"default_branch":"master"}},"base":{"label":"sourcecred:master","ref":"master","sha":"55225fd53e2bf745ddc0e7288261e01bfdc7ff7f","user":{"login":"sourcecred","id":35711667,"avatar_url":"https://avatars1.githubusercontent.com/u/35711667?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcecred","html_url":"https://github.com/sourcecred","followers_url":"https://api.github.com/users/sourcecred/followers","following_url":"https://api.github.com/users/sourcecred/following{/other_user}","gists_url":"https://api.github.com/users/sourcecred/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcecred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcecred/subscriptions","organizations_url":"https://api.github.com/users/sourcecred/orgs","repos_url":"https://api.github.com/users/sourcecred/repos","events_url":"https://api.github.com/users/sourcecred/events{/privacy}","received_events_url":"https://api.github.com/users/sourcecred/received_events","type":"Organization","site_admin":false},"repo":{"id":120145570,"name":"sourcecred","full_name":"sourcecred/sourcecred","owner":{"login":"sourcecred","id":35711667,"avatar_url":"https://avatars1.githubusercontent.com/u/35711667?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcecred","html_url":"https://github.com/sourcecred","followers_url":"https://api.github.com/users/sourcecred/followers","following_url":"https://api.github.com/users/sourcecred/following{/other_user}","gists_url":"https://api.github.com/users/sourcecred/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcecred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcecred/subscriptions","organizations_url":"https://api.github.com/users/sourcecred/orgs","repos_url":"https://api.github.com/users/sourcecred/repos","events_url":"https://api.github.com/users/sourcecred/events{/privacy}","received_events_url":"https://api.github.com/users/sourcecred/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sourcecred/sourcecred","description":"credit attribution for open-source projects. like street cred, for source code.","fork":false,"url":"https://api.github.com/repos/sourcecred/sourcecred","forks_url":"https://api.github.com/repos/sourcecred/sourcecred/forks","keys_url":"https://api.github.com/repos/sourcecred/sourcecred/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sourcecred/sourcecred/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sourcecred/sourcecred/teams","hooks_url":"https://api.github.com/repos/sourcecred/sourcecred/hooks","issue_events_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/events{/number}","events_url":"https://api.github.com/repos/sourcecred/sourcecred/events","assignees_url":"https://api.github.com/repos/sourcecred/sourcecred/assignees{/user}","branches_url":"https://api.github.com/repos/sourcecred/sourcecred/branches{/branch}","tags_url":"https://api.github.com/repos/sourcecred/sourcecred/tags","blobs_url":"https://api.github.com/repos/sourcecred/sourcecred/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sourcecred/sourcecred/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sourcecred/sourcecred/git/refs{/sha}","trees_url":"https://api.github.com/repos/sourcecred/sourcecred/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sourcecred/sourcecred/statuses/{sha}","languages_url":"https://api.github.com/repos/sourcecred/sourcecred/languages","stargazers_url":"https://api.github.com/repos/sourcecred/sourcecred/stargazers","contributors_url":"https://api.github.com/repos/sourcecred/sourcecred/contributors","subscribers_url":"https://api.github.com/repos/sourcecred/sourcecred/subscribers","subscription_url":"https://api.github.com/repos/sourcecred/sourcecred/subscription","commits_url":"https://api.github.com/repos/sourcecred/sourcecred/commits{/sha}","git_commits_url":"https://api.github.com/repos/sourcecred/sourcecred/git/commits{/sha}","comments_url":"https://api.github.com/repos/sourcecred/sourcecred/comments{/number}","issue_comment_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/comments{/number}","contents_url":"https://api.github.com/repos/sourcecred/sourcecred/contents/{+path}","compare_url":"https://api.github.com/repos/sourcecred/sourcecred/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sourcecred/sourcecred/merges","archive_url":"https://api.github.com/repos/sourcecred/sourcecred/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sourcecred/sourcecred/downloads","issues_url":"https://api.github.com/repos/sourcecred/sourcecred/issues{/number}","pulls_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls{/number}","milestones_url":"https://api.github.com/repos/sourcecred/sourcecred/milestones{/number}","notifications_url":"https://api.github.com/repos/sourcecred/sourcecred/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sourcecred/sourcecred/labels{/name}","releases_url":"https://api.github.com/repos/sourcecred/sourcecred/releases{/id}","deployments_url":"https://api.github.com/repos/sourcecred/sourcecred/deployments","created_at":"2018-02-04T01:32:53Z","updated_at":"2018-03-20T03:06:56Z","pushed_at":"2018-03-20T15:12:38Z","git_url":"git://github.com/sourcecred/sourcecred.git","ssh_url":"git@github.com:sourcecred/sourcecred.git","clone_url":"https://github.com/sourcecred/sourcecred.git","svn_url":"https://github.com/sourcecred/sourcecred","homepage":"","size":497,"stargazers_count":13,"watchers_count":13,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":16,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":16,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/94"},"html":{"href":"https://github.com/sourcecred/sourcecred/pull/94"},"issue":{"href":"https://api.github.com/repos/sourcecred/sourcecred/issues/94"},"comments":{"href":"https://api.github.com/repos/sourcecred/sourcecred/issues/94/comments"},"review_comments":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/94/comments"},"review_comment":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/94/commits"},"statuses":{"href":"https://api.github.com/repos/sourcecred/sourcecred/statuses/d3d9b42bf39e0890fee8ac1781a9c97e1c9d1852"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"dandelionmane"}}