{"action":"created","comment":{"url":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/comments/88966569","pull_request_review_id":9519955,"id":88966569,"diff_hunk":"@@ -1,20 +1,47 @@\n-import { print } from 'graphql/language/printer'\n-import { parse } from 'graphql/language/parser'\n-import crypto from 'crypto'\n+import { parseQuery, QueryRepository, QueryNotFoundError } from './utils'\n \n const noop = () => { }\n \n-export default ({ validateFn, skipValidationFn = noop, validationErrorFn = noop }) =>\n-  async (req, res, next) => {\n+export default ({ store, skipValidationFn = noop, validationErrorFn = noop }) => {\n+  const repository = new QueryRepository(store)\n+\n+  return async (req, res, next) => {\n+    const unauthorized = (errorCode) => {\n+      validationErrorFn(req, { errorCode })\n+      res.status(401).json({ error: 'Unauthorized query' })\n+    }\n+\n     if (skipValidationFn(req)) return next()\n \n-    req.normalizedQuery = print(parse(req.body.query))\n-    req.queryHash = crypto.createHash('sha256').update(req.normalizedQuery).digest('base64')\n+    const queryId = req.body.queryId || req.query.queryId\n+    let queryObj = {}\n \n-    if (await validateFn(req.queryHash)) {\n-      next()\n+    if (queryId) {\n+      queryObj = { queryId }\n+    } else if (req.body.query) {\n+      queryObj = parseQuery(req.body.query)\n     } else {\n-      validationErrorFn(req)\n-      res.status(401).send('Unauthorized query')\n+      // no queryId or query was specified. Let express-grapqhl handle this\n+      next()\n+    }\n+\n+    try {\n+      const { query, enabled } = await repository.get(queryObj.queryId)","path":"lib/index.js","position":40,"original_position":40,"commit_id":"47f0bd37bb79e03a4a3f8228e1add9691cdb6958","original_commit_id":"09b6b451af0dc2cf3f9e6b25612d3c622f19d640","user":{"login":"jfresco","id":4335188,"avatar_url":"https://avatars.githubusercontent.com/u/4335188?v=3","gravatar_id":"","url":"https://api.github.com/users/jfresco","html_url":"https://github.com/jfresco","followers_url":"https://api.github.com/users/jfresco/followers","following_url":"https://api.github.com/users/jfresco/following{/other_user}","gists_url":"https://api.github.com/users/jfresco/gists{/gist_id}","starred_url":"https://api.github.com/users/jfresco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfresco/subscriptions","organizations_url":"https://api.github.com/users/jfresco/orgs","repos_url":"https://api.github.com/users/jfresco/repos","events_url":"https://api.github.com/users/jfresco/events{/privacy}","received_events_url":"https://api.github.com/users/jfresco/received_events","type":"User","site_admin":false},"body":"Si `get` devuelve `undefined` va a dar error y entrar al `catch` directo. Es el comportamiento deseado?","created_at":"2016-11-21T19:15:38Z","updated_at":"2016-11-21T19:18:40Z","html_url":"https://github.com/restorando/graphql-query-whitelist/pull/2#discussion_r88966569","pull_request_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/comments/88966569"},"html":{"href":"https://github.com/restorando/graphql-query-whitelist/pull/2#discussion_r88966569"},"pull_request":{"href":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/2","id":93801103,"html_url":"https://github.com/restorando/graphql-query-whitelist/pull/2","diff_url":"https://github.com/restorando/graphql-query-whitelist/pull/2.diff","patch_url":"https://github.com/restorando/graphql-query-whitelist/pull/2.patch","issue_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/issues/2","number":2,"state":"open","locked":false,"title":"add stores","user":{"login":"gschammah","id":591992,"avatar_url":"https://avatars.githubusercontent.com/u/591992?v=3","gravatar_id":"","url":"https://api.github.com/users/gschammah","html_url":"https://github.com/gschammah","followers_url":"https://api.github.com/users/gschammah/followers","following_url":"https://api.github.com/users/gschammah/following{/other_user}","gists_url":"https://api.github.com/users/gschammah/gists{/gist_id}","starred_url":"https://api.github.com/users/gschammah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gschammah/subscriptions","organizations_url":"https://api.github.com/users/gschammah/orgs","repos_url":"https://api.github.com/users/gschammah/repos","events_url":"https://api.github.com/users/gschammah/events{/privacy}","received_events_url":"https://api.github.com/users/gschammah/received_events","type":"User","site_admin":false},"body":"@jfresco @joaquinstan me falta actualizar el readme y cambiarle el nombre a la libreria. \r\n\r\nLo podran ver? cambio muchisimo","created_at":"2016-11-15T16:35:41Z","updated_at":"2016-11-21T19:18:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3fdff020fe296b5d9ef76d370b709655d0d5454a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/2/commits","review_comments_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/2/comments","review_comment_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/comments{/number}","comments_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/issues/2/comments","statuses_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/statuses/47f0bd37bb79e03a4a3f8228e1add9691cdb6958","head":{"label":"restorando:feature/stores","ref":"feature/stores","sha":"47f0bd37bb79e03a4a3f8228e1add9691cdb6958","user":{"login":"restorando","id":709444,"avatar_url":"https://avatars.githubusercontent.com/u/709444?v=3","gravatar_id":"","url":"https://api.github.com/users/restorando","html_url":"https://github.com/restorando","followers_url":"https://api.github.com/users/restorando/followers","following_url":"https://api.github.com/users/restorando/following{/other_user}","gists_url":"https://api.github.com/users/restorando/gists{/gist_id}","starred_url":"https://api.github.com/users/restorando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/restorando/subscriptions","organizations_url":"https://api.github.com/users/restorando/orgs","repos_url":"https://api.github.com/users/restorando/repos","events_url":"https://api.github.com/users/restorando/events{/privacy}","received_events_url":"https://api.github.com/users/restorando/received_events","type":"Organization","site_admin":false},"repo":{"id":72154456,"name":"graphql-query-whitelist","full_name":"restorando/graphql-query-whitelist","owner":{"login":"restorando","id":709444,"avatar_url":"https://avatars.githubusercontent.com/u/709444?v=3","gravatar_id":"","url":"https://api.github.com/users/restorando","html_url":"https://github.com/restorando","followers_url":"https://api.github.com/users/restorando/followers","following_url":"https://api.github.com/users/restorando/following{/other_user}","gists_url":"https://api.github.com/users/restorando/gists{/gist_id}","starred_url":"https://api.github.com/users/restorando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/restorando/subscriptions","organizations_url":"https://api.github.com/users/restorando/orgs","repos_url":"https://api.github.com/users/restorando/repos","events_url":"https://api.github.com/users/restorando/events{/privacy}","received_events_url":"https://api.github.com/users/restorando/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/restorando/graphql-query-whitelist","description":"GraphQL query whitelisting middleware","fork":false,"url":"https://api.github.com/repos/restorando/graphql-query-whitelist","forks_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/forks","keys_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/keys{/key_id}","collaborators_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/teams","hooks_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/hooks","issue_events_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/issues/events{/number}","events_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/events","assignees_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/assignees{/user}","branches_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/branches{/branch}","tags_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/tags","blobs_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/git/refs{/sha}","trees_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/git/trees{/sha}","statuses_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/statuses/{sha}","languages_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/languages","stargazers_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/stargazers","contributors_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/contributors","subscribers_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/subscribers","subscription_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/subscription","commits_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/commits{/sha}","git_commits_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/git/commits{/sha}","comments_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/comments{/number}","issue_comment_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/issues/comments{/number}","contents_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/contents/{+path}","compare_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/compare/{base}...{head}","merges_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/merges","archive_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/downloads","issues_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/issues{/number}","pulls_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls{/number}","milestones_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/milestones{/number}","notifications_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/labels{/name}","releases_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/releases{/id}","deployments_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/deployments","created_at":"2016-10-27T22:49:59Z","updated_at":"2016-11-21T15:25:50Z","pushed_at":"2016-11-21T19:15:24Z","git_url":"git://github.com/restorando/graphql-query-whitelist.git","ssh_url":"git@github.com:restorando/graphql-query-whitelist.git","clone_url":"https://github.com/restorando/graphql-query-whitelist.git","svn_url":"https://github.com/restorando/graphql-query-whitelist","homepage":null,"size":24,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":5,"default_branch":"master"}},"base":{"label":"restorando:master","ref":"master","sha":"1802b2450eea0179f8ddc359cf07804e1508aada","user":{"login":"restorando","id":709444,"avatar_url":"https://avatars.githubusercontent.com/u/709444?v=3","gravatar_id":"","url":"https://api.github.com/users/restorando","html_url":"https://github.com/restorando","followers_url":"https://api.github.com/users/restorando/followers","following_url":"https://api.github.com/users/restorando/following{/other_user}","gists_url":"https://api.github.com/users/restorando/gists{/gist_id}","starred_url":"https://api.github.com/users/restorando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/restorando/subscriptions","organizations_url":"https://api.github.com/users/restorando/orgs","repos_url":"https://api.github.com/users/restorando/repos","events_url":"https://api.github.com/users/restorando/events{/privacy}","received_events_url":"https://api.github.com/users/restorando/received_events","type":"Organization","site_admin":false},"repo":{"id":72154456,"name":"graphql-query-whitelist","full_name":"restorando/graphql-query-whitelist","owner":{"login":"restorando","id":709444,"avatar_url":"https://avatars.githubusercontent.com/u/709444?v=3","gravatar_id":"","url":"https://api.github.com/users/restorando","html_url":"https://github.com/restorando","followers_url":"https://api.github.com/users/restorando/followers","following_url":"https://api.github.com/users/restorando/following{/other_user}","gists_url":"https://api.github.com/users/restorando/gists{/gist_id}","starred_url":"https://api.github.com/users/restorando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/restorando/subscriptions","organizations_url":"https://api.github.com/users/restorando/orgs","repos_url":"https://api.github.com/users/restorando/repos","events_url":"https://api.github.com/users/restorando/events{/privacy}","received_events_url":"https://api.github.com/users/restorando/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/restorando/graphql-query-whitelist","description":"GraphQL query whitelisting middleware","fork":false,"url":"https://api.github.com/repos/restorando/graphql-query-whitelist","forks_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/forks","keys_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/keys{/key_id}","collaborators_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/teams","hooks_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/hooks","issue_events_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/issues/events{/number}","events_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/events","assignees_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/assignees{/user}","branches_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/branches{/branch}","tags_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/tags","blobs_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/git/refs{/sha}","trees_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/git/trees{/sha}","statuses_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/statuses/{sha}","languages_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/languages","stargazers_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/stargazers","contributors_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/contributors","subscribers_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/subscribers","subscription_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/subscription","commits_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/commits{/sha}","git_commits_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/git/commits{/sha}","comments_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/comments{/number}","issue_comment_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/issues/comments{/number}","contents_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/contents/{+path}","compare_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/compare/{base}...{head}","merges_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/merges","archive_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/downloads","issues_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/issues{/number}","pulls_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls{/number}","milestones_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/milestones{/number}","notifications_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/labels{/name}","releases_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/releases{/id}","deployments_url":"https://api.github.com/repos/restorando/graphql-query-whitelist/deployments","created_at":"2016-10-27T22:49:59Z","updated_at":"2016-11-21T15:25:50Z","pushed_at":"2016-11-21T19:15:24Z","git_url":"git://github.com/restorando/graphql-query-whitelist.git","ssh_url":"git@github.com:restorando/graphql-query-whitelist.git","clone_url":"https://github.com/restorando/graphql-query-whitelist.git","svn_url":"https://github.com/restorando/graphql-query-whitelist","homepage":null,"size":24,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/2"},"html":{"href":"https://github.com/restorando/graphql-query-whitelist/pull/2"},"issue":{"href":"https://api.github.com/repos/restorando/graphql-query-whitelist/issues/2"},"comments":{"href":"https://api.github.com/repos/restorando/graphql-query-whitelist/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/restorando/graphql-query-whitelist/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/restorando/graphql-query-whitelist/statuses/47f0bd37bb79e03a4a3f8228e1add9691cdb6958"}}}}
{"actor":{"display_login":"jfresco"}}