Skip to content
Snippets Groups Projects
Commit c56362f6 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

refactor(github): better log query during error

parent 1ab9b09d
Branches
Tags
No related merge requests found
...@@ -840,6 +840,7 @@ async function createPr( ...@@ -840,6 +840,7 @@ async function createPr(
async function getOpenPrs() { async function getOpenPrs() {
if (!config.openPrList) { if (!config.openPrList) {
config.openPrList = {}; config.openPrList = {};
let query;
try { try {
const url = 'graphql'; const url = 'graphql';
// https://developer.github.com/v4/previews/#mergeinfopreview---more-detailed-information-about-a-pull-requests-merge-state // https://developer.github.com/v4/previews/#mergeinfopreview---more-detailed-information-about-a-pull-requests-merge-state
...@@ -847,7 +848,7 @@ async function getOpenPrs() { ...@@ -847,7 +848,7 @@ async function getOpenPrs() {
accept: 'application/vnd.github.merge-info-preview+json', accept: 'application/vnd.github.merge-info-preview+json',
}; };
// prettier-ignore // prettier-ignore
const query = ` query = `
query { query {
repository(owner: "${config.repositoryOwner}", name: "${config.repositoryName}") { repository(owner: "${config.repositoryOwner}", name: "${config.repositoryName}") {
pullRequests(states: [OPEN], first: 100, orderBy: {field: UPDATED_AT, direction: DESC}) { pullRequests(states: [OPEN], first: 100, orderBy: {field: UPDATED_AT, direction: DESC}) {
...@@ -953,7 +954,7 @@ async function getOpenPrs() { ...@@ -953,7 +954,7 @@ async function getOpenPrs() {
prNumbers.sort(); prNumbers.sort();
logger.debug({ prNumbers }, 'Retrieved open PR list with graphql'); logger.debug({ prNumbers }, 'Retrieved open PR list with graphql');
} catch (err) /* istanbul ignore next */ { } catch (err) /* istanbul ignore next */ {
logger.warn({ err }, 'getOpenPrs error'); logger.warn({ query, err }, 'getOpenPrs error');
} }
} }
return config.openPrList; return config.openPrList;
...@@ -962,10 +963,11 @@ async function getOpenPrs() { ...@@ -962,10 +963,11 @@ async function getOpenPrs() {
async function getClosedPrs() { async function getClosedPrs() {
if (!config.closedPrList) { if (!config.closedPrList) {
config.closedPrList = {}; config.closedPrList = {};
let query;
try { try {
const url = 'graphql'; const url = 'graphql';
// prettier-ignore // prettier-ignore
const query = ` query = `
query { query {
repository(owner: "${config.repositoryOwner}", name: "${config.repositoryName}") { repository(owner: "${config.repositoryOwner}", name: "${config.repositoryName}") {
pullRequests(states: [CLOSED, MERGED], first: 100, orderBy: {field: UPDATED_AT, direction: DESC}) { pullRequests(states: [CLOSED, MERGED], first: 100, orderBy: {field: UPDATED_AT, direction: DESC}) {
...@@ -1013,7 +1015,7 @@ async function getClosedPrs() { ...@@ -1013,7 +1015,7 @@ async function getClosedPrs() {
prNumbers.sort(); prNumbers.sort();
logger.debug({ prNumbers }, 'Retrieved closed PR list with graphql'); logger.debug({ prNumbers }, 'Retrieved closed PR list with graphql');
} catch (err) /* istanbul ignore next */ { } catch (err) /* istanbul ignore next */ {
logger.warn({ err }, 'getOpenPrs error'); logger.warn({ query, err }, 'getOpenPrs error');
} }
} }
return config.closedPrList; return config.closedPrList;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment