diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js index 9fb79e9789219a..6cfdcf5f142344 100644 --- a/src/fetchers/stats-fetcher.js +++ b/src/fetchers/stats-fetcher.js @@ -121,7 +121,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 fe1958694962e0..9e9515604fc80e 100644 --- a/src/fetchers/top-languages-fetcher.js +++ b/src/fetchers/top-languages-fetcher.js @@ -47,6 +47,11 @@ const fetcher = (variables, token) => { async function fetchTopLanguages(username, ownerAffiliations, exclude_repo = []) { if (!username) throw new MissingParamError(["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) {