diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js index 73dc9690..3ee0964e 100644 --- a/src/fetchers/stats-fetcher.js +++ b/src/fetchers/stats-fetcher.js @@ -105,7 +105,12 @@ async function fetchStats( rank: { level: "C", score: 0 }, }; - let res = await retryer(fetcher, { login: username, ownerAffiliations}); + // Set default value for ownerAffiliations in GraphQL query won't work because + // parseArray() will always return an empty array even nothing was specified + // and GraphQL would consider that empty arr as a valid value. Nothing will be + // queried in that case as no affiliation is presented. + ownerAffiliations = ownerAffiliations.length > 0 ? ownerAffiliations : ["OWNER"]; + let res = await retryer(fetcher, { login: username, ownerAffiliations }); if (res.data.errors) { logger.error(res.data.errors); diff --git a/src/fetchers/top-languages-fetcher.js b/src/fetchers/top-languages-fetcher.js index d3e150f1..99a25f9e 100644 --- a/src/fetchers/top-languages-fetcher.js +++ b/src/fetchers/top-languages-fetcher.js @@ -37,6 +37,11 @@ const fetcher = (variables, token) => { async function fetchTopLanguages(username, exclude_repo = [], ownerAffiliations) { if (!username) throw Error("Invalid username"); + // Set default value for ownerAffiliations in GraphQL query won't work because + // parseArray() will always return an empty array even nothing was specified + // and GraphQL would consider that empty arr as a valid value. Nothing will be + // queried in that case as no affiliation is presented. + ownerAffiliations = ownerAffiliations.length > 0 ? ownerAffiliations : ["OWNER"]; const res = await retryer(fetcher, { login: username, ownerAffiliations }); if (res.data.errors) {