From d907bd4b2f76f508c30cd5f9829fc88666d97806 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Tue, 11 Sep 2018 15:22:05 +0200 Subject: [PATCH] Revert "fix(github): parse graphql json in wrapper" This reverts commit da7b4e6899589ddabeb80a9fbaa7532effefc58b. --- lib/platform/github/gh-got-wrapper.js | 15 ++++++--------- lib/platform/github/index.js | 6 +++--- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/platform/github/gh-got-wrapper.js b/lib/platform/github/gh-got-wrapper.js index cb827e5898..3d09a0ccdf 100644 --- a/lib/platform/github/gh-got-wrapper.js +++ b/lib/platform/github/gh-got-wrapper.js @@ -80,15 +80,12 @@ async function get(path, options, retries = 5) { } // istanbul ignore if if (method === 'POST' && path === 'graphql') { - if (res.body) { - res.body = JSON.parse(res.body); - if (res.body.errors && retries > 0) { - logger.info('Retrying graphql query'); - return get(path, opts, 0); - } - if (res.body.data && retries === 0) { - logger.info('Recovered graphql query'); - } + if (res.errors && retries > 0) { + logger.info('Retrying graphql query'); + return get(path, opts, 0); + } + if (res.data && retries === 0) { + logger.info('Recovered graphql query'); } } return res; diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index a040e6681d..eb97aea0e6 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -889,7 +889,7 @@ async function getOpenPrs() { body: JSON.stringify({ query }), json: false, }; - const res = (await get.post(url, options)).body; + const res = JSON.parse((await get.post(url, options)).body); const prNumbers = []; // istanbul ignore if if (!res.data) { @@ -991,7 +991,7 @@ async function getClosedPrs() { body: JSON.stringify({ query }), json: false, }; - const res = (await get.post(url, options)).body; + const res = JSON.parse((await get.post(url, options)).body); const prNumbers = []; // istanbul ignore if if (!res.data) { @@ -1294,7 +1294,7 @@ async function getVulnerabilityAlerts() { }; let alerts = []; try { - const res = (await get.post(url, options)).body; + const res = JSON.parse((await get.post(url, options)).body); if (res.data.repository.vulnerabilityAlerts) { alerts = res.data.repository.vulnerabilityAlerts.edges.map( edge => edge.node -- GitLab