{"action":"created","comment":{"url":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/comments/193153371","pull_request_review_id":126069313,"id":193153371,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MzE1MzM3MQ==","diff_hunk":"@@ -17,6 +17,10 @@ const onCreateNode = async (\n   const query = await loadNodeContent(node)\n   const queries = [ query ]\n \n+  // Resolve configurations.\n+  config = 'then' in config ? await config : config;\n+  const { headers = {}, url, variables = {} } = config;","path":"src/on-create-node.ts","position":15,"original_position":15,"commit_id":"abb79d41ddac91fb5ca318e9aed4babaffdbe41b","original_commit_id":"abb79d41ddac91fb5ca318e9aed4babaffdbe41b","user":{"login":"wyze","id":186971,"node_id":"MDQ6VXNlcjE4Njk3MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/186971?v=4","gravatar_id":"","url":"https://api.github.com/users/wyze","html_url":"https://github.com/wyze","followers_url":"https://api.github.com/users/wyze/followers","following_url":"https://api.github.com/users/wyze/following{/other_user}","gists_url":"https://api.github.com/users/wyze/gists{/gist_id}","starred_url":"https://api.github.com/users/wyze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wyze/subscriptions","organizations_url":"https://api.github.com/users/wyze/orgs","repos_url":"https://api.github.com/users/wyze/repos","events_url":"https://api.github.com/users/wyze/events{/privacy}","received_events_url":"https://api.github.com/users/wyze/received_events","type":"User","site_admin":false},"body":"There is no need for the reassignement here. You can `await <value>` and it will just return that value if it's not a Promise.\r\n\r\n```diff\r\n-  config = 'then' in config ? await config : config;\r\n-  const { headers = {}, url, variables = {} } = config;\r\n+  const { headers = {}, url, variables = {} } = await config;\r\n```","created_at":"2018-06-05T17:17:12Z","updated_at":"2018-06-05T17:17:29Z","html_url":"https://github.com/wyze/gatsby-source-graphql/pull/4#discussion_r193153371","pull_request_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/4","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/comments/193153371"},"html":{"href":"https://github.com/wyze/gatsby-source-graphql/pull/4#discussion_r193153371"},"pull_request":{"href":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/4","id":192725632,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyNzI1NjMy","html_url":"https://github.com/wyze/gatsby-source-graphql/pull/4","diff_url":"https://github.com/wyze/gatsby-source-graphql/pull/4.diff","patch_url":"https://github.com/wyze/gatsby-source-graphql/pull/4.patch","issue_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/issues/4","number":4,"state":"open","locked":false,"title":"Allow a promise for asynchronously loading configs","user":{"login":"janthonyeconomist","id":1117343,"node_id":"MDQ6VXNlcjExMTczNDM=","avatar_url":"https://avatars0.githubusercontent.com/u/1117343?v=4","gravatar_id":"","url":"https://api.github.com/users/janthonyeconomist","html_url":"https://github.com/janthonyeconomist","followers_url":"https://api.github.com/users/janthonyeconomist/followers","following_url":"https://api.github.com/users/janthonyeconomist/following{/other_user}","gists_url":"https://api.github.com/users/janthonyeconomist/gists{/gist_id}","starred_url":"https://api.github.com/users/janthonyeconomist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janthonyeconomist/subscriptions","organizations_url":"https://api.github.com/users/janthonyeconomist/orgs","repos_url":"https://api.github.com/users/janthonyeconomist/repos","events_url":"https://api.github.com/users/janthonyeconomist/events{/privacy}","received_events_url":"https://api.github.com/users/janthonyeconomist/received_events","type":"User","site_admin":false},"body":"Would you be okay with allowing the options to be defined as a promise that will resolve to the options?\r\n\r\n## Problem:\r\nI need to dynamically request a JWT token for authorization of the GraphQL request, so I can't just define it in the plugin config as such:\r\n```\r\n    {\r\n      resolve: 'gatsby-source-graphql',\r\n      options: {\r\n        headers: {\r\n          authorization: `Bearer ${process.env.GITHUB_TOKEN}`,\r\n        },\r\n        url: 'https://api.github.com/graphql',\r\n      },\r\n    },\r\n```\r\n## Solution:\r\nInstead, it would be great to be able to request the token and asynchronously resolve to the configs.  Something like so:\r\n```\r\n    {\r\n      resolve: 'gatsby-source-graphql',\r\n      options: getAuthToken().then(token => ({\r\n        headers: {\r\n          authorization: `Bearer ${token}`,\r\n        },\r\n        url: 'https://example.com/graphql',\r\n      })),\r\n    },\r\n```","created_at":"2018-06-05T14:23:41Z","updated_at":"2018-06-05T17:17:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"004166cb725baebae1968edd51747fa19cb9a2b7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/4/commits","review_comments_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/4/comments","review_comment_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/issues/4/comments","statuses_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/statuses/abb79d41ddac91fb5ca318e9aed4babaffdbe41b","head":{"label":"EconomistWhichMBA:master","ref":"master","sha":"abb79d41ddac91fb5ca318e9aed4babaffdbe41b","user":{"login":"EconomistWhichMBA","id":5973629,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU5NzM2Mjk=","avatar_url":"https://avatars1.githubusercontent.com/u/5973629?v=4","gravatar_id":"","url":"https://api.github.com/users/EconomistWhichMBA","html_url":"https://github.com/EconomistWhichMBA","followers_url":"https://api.github.com/users/EconomistWhichMBA/followers","following_url":"https://api.github.com/users/EconomistWhichMBA/following{/other_user}","gists_url":"https://api.github.com/users/EconomistWhichMBA/gists{/gist_id}","starred_url":"https://api.github.com/users/EconomistWhichMBA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EconomistWhichMBA/subscriptions","organizations_url":"https://api.github.com/users/EconomistWhichMBA/orgs","repos_url":"https://api.github.com/users/EconomistWhichMBA/repos","events_url":"https://api.github.com/users/EconomistWhichMBA/events{/privacy}","received_events_url":"https://api.github.com/users/EconomistWhichMBA/received_events","type":"Organization","site_admin":false},"repo":{"id":136180738,"node_id":"MDEwOlJlcG9zaXRvcnkxMzYxODA3Mzg=","name":"gatsby-source-graphql","full_name":"EconomistWhichMBA/gatsby-source-graphql","owner":{"login":"EconomistWhichMBA","id":5973629,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU5NzM2Mjk=","avatar_url":"https://avatars1.githubusercontent.com/u/5973629?v=4","gravatar_id":"","url":"https://api.github.com/users/EconomistWhichMBA","html_url":"https://github.com/EconomistWhichMBA","followers_url":"https://api.github.com/users/EconomistWhichMBA/followers","following_url":"https://api.github.com/users/EconomistWhichMBA/following{/other_user}","gists_url":"https://api.github.com/users/EconomistWhichMBA/gists{/gist_id}","starred_url":"https://api.github.com/users/EconomistWhichMBA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EconomistWhichMBA/subscriptions","organizations_url":"https://api.github.com/users/EconomistWhichMBA/orgs","repos_url":"https://api.github.com/users/EconomistWhichMBA/repos","events_url":"https://api.github.com/users/EconomistWhichMBA/events{/privacy}","received_events_url":"https://api.github.com/users/EconomistWhichMBA/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/EconomistWhichMBA/gatsby-source-graphql","description":"A Gatsby source plugin for pulling in data from GraphQL APIs.","fork":true,"url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql","forks_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/forks","keys_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/teams","hooks_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/hooks","issue_events_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/issues/events{/number}","events_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/events","assignees_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/assignees{/user}","branches_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/branches{/branch}","tags_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/tags","blobs_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/git/refs{/sha}","trees_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/statuses/{sha}","languages_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/languages","stargazers_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/stargazers","contributors_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/contributors","subscribers_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/subscribers","subscription_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/subscription","commits_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/commits{/sha}","git_commits_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/git/commits{/sha}","comments_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/comments{/number}","issue_comment_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/issues/comments{/number}","contents_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/contents/{+path}","compare_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/merges","archive_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/downloads","issues_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/issues{/number}","pulls_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/pulls{/number}","milestones_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/milestones{/number}","notifications_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/labels{/name}","releases_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/releases{/id}","deployments_url":"https://api.github.com/repos/EconomistWhichMBA/gatsby-source-graphql/deployments","created_at":"2018-06-05T13:21:48Z","updated_at":"2018-06-05T14:40:56Z","pushed_at":"2018-06-05T14:40:54Z","git_url":"git://github.com/EconomistWhichMBA/gatsby-source-graphql.git","ssh_url":"git@github.com:EconomistWhichMBA/gatsby-source-graphql.git","clone_url":"https://github.com/EconomistWhichMBA/gatsby-source-graphql.git","svn_url":"https://github.com/EconomistWhichMBA/gatsby-source-graphql","homepage":"https://yarn.pm/gatsby-source-graphql","size":54,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wyze:master","ref":"master","sha":"4471e2c2215960d6dbc7da46c7b2b817d0e92e74","user":{"login":"wyze","id":186971,"node_id":"MDQ6VXNlcjE4Njk3MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/186971?v=4","gravatar_id":"","url":"https://api.github.com/users/wyze","html_url":"https://github.com/wyze","followers_url":"https://api.github.com/users/wyze/followers","following_url":"https://api.github.com/users/wyze/following{/other_user}","gists_url":"https://api.github.com/users/wyze/gists{/gist_id}","starred_url":"https://api.github.com/users/wyze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wyze/subscriptions","organizations_url":"https://api.github.com/users/wyze/orgs","repos_url":"https://api.github.com/users/wyze/repos","events_url":"https://api.github.com/users/wyze/events{/privacy}","received_events_url":"https://api.github.com/users/wyze/received_events","type":"User","site_admin":false},"repo":{"id":132349655,"node_id":"MDEwOlJlcG9zaXRvcnkxMzIzNDk2NTU=","name":"gatsby-source-graphql","full_name":"wyze/gatsby-source-graphql","owner":{"login":"wyze","id":186971,"node_id":"MDQ6VXNlcjE4Njk3MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/186971?v=4","gravatar_id":"","url":"https://api.github.com/users/wyze","html_url":"https://github.com/wyze","followers_url":"https://api.github.com/users/wyze/followers","following_url":"https://api.github.com/users/wyze/following{/other_user}","gists_url":"https://api.github.com/users/wyze/gists{/gist_id}","starred_url":"https://api.github.com/users/wyze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wyze/subscriptions","organizations_url":"https://api.github.com/users/wyze/orgs","repos_url":"https://api.github.com/users/wyze/repos","events_url":"https://api.github.com/users/wyze/events{/privacy}","received_events_url":"https://api.github.com/users/wyze/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wyze/gatsby-source-graphql","description":"A Gatsby source plugin for pulling in data from GraphQL APIs.","fork":false,"url":"https://api.github.com/repos/wyze/gatsby-source-graphql","forks_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/forks","keys_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/teams","hooks_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/hooks","issue_events_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/issues/events{/number}","events_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/events","assignees_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/assignees{/user}","branches_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/branches{/branch}","tags_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/tags","blobs_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/git/refs{/sha}","trees_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/statuses/{sha}","languages_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/languages","stargazers_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/stargazers","contributors_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/contributors","subscribers_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/subscribers","subscription_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/subscription","commits_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/commits{/sha}","git_commits_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/git/commits{/sha}","comments_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/comments{/number}","issue_comment_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/issues/comments{/number}","contents_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/contents/{+path}","compare_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/merges","archive_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/downloads","issues_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/issues{/number}","pulls_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls{/number}","milestones_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/milestones{/number}","notifications_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/labels{/name}","releases_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/releases{/id}","deployments_url":"https://api.github.com/repos/wyze/gatsby-source-graphql/deployments","created_at":"2018-05-06T15:07:17Z","updated_at":"2018-05-31T13:34:54Z","pushed_at":"2018-06-05T14:40:55Z","git_url":"git://github.com/wyze/gatsby-source-graphql.git","ssh_url":"git@github.com:wyze/gatsby-source-graphql.git","clone_url":"https://github.com/wyze/gatsby-source-graphql.git","svn_url":"https://github.com/wyze/gatsby-source-graphql","homepage":"https://yarn.pm/gatsby-source-graphql","size":53,"stargazers_count":2,"watchers_count":2,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":2,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/4"},"html":{"href":"https://github.com/wyze/gatsby-source-graphql/pull/4"},"issue":{"href":"https://api.github.com/repos/wyze/gatsby-source-graphql/issues/4"},"comments":{"href":"https://api.github.com/repos/wyze/gatsby-source-graphql/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wyze/gatsby-source-graphql/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/wyze/gatsby-source-graphql/statuses/abb79d41ddac91fb5ca318e9aed4babaffdbe41b"}},"author_association":"NONE"}}
{"actor":{"display_login":"wyze"}}