Skip to content

Commit 1badb9c

Browse files
committed
Add default affiliation
1 parent 3855938 commit 1badb9c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/fetchers/stats-fetcher.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ async function fetchStats(
102102
rank: { level: "C", score: 0 },
103103
};
104104

105-
let res = await retryer(fetcher, { login: username, ownerAffiliations});
105+
// Set default value for ownerAffiliations in GraphQL query won't work because
106+
// parseArray() will always return an empty array even nothing was specified
107+
// and GraphQL would consider that empty arr as a valid value. Nothing will be
108+
// queried in that case as no affiliation is presented.
109+
ownerAffiliations = ownerAffiliations.length > 0 ? ownerAffiliations : ["OWNER"];
110+
let res = await retryer(fetcher, { login: username, ownerAffiliations });
106111

107112
if (res.data.errors) {
108113
logger.error(res.data.errors);

src/fetchers/top-languages-fetcher.js

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ const fetcher = (variables, token) => {
3737
async function fetchTopLanguages(username, exclude_repo = [], ownerAffiliations) {
3838
if (!username) throw Error("Invalid username");
3939

40+
// Set default value for ownerAffiliations in GraphQL query won't work because
41+
// parseArray() will always return an empty array even nothing was specified
42+
// and GraphQL would consider that empty arr as a valid value. Nothing will be
43+
// queried in that case as no affiliation is presented.
44+
ownerAffiliations = ownerAffiliations.length > 0 ? ownerAffiliations : ["OWNER"];
4045
const res = await retryer(fetcher, { login: username, ownerAffiliations });
4146

4247
if (res.data.errors) {

0 commit comments

Comments
 (0)