Skip to content

Commit dfc44b6

Browse files
committed
Add default affiliation
1 parent f19d94f commit dfc44b6

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
@@ -105,7 +105,12 @@ async function fetchStats(
105105
rank: { level: "C", score: 0 },
106106
};
107107

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

110115
if (res.data.errors) {
111116
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)