Add default affiliation

This commit is contained in:
devStorm
2021-12-04 15:19:19 -05:00
parent f19d94f270
commit dfc44b63b8
2 changed files with 11 additions and 1 deletions
+6 -1
View File
@@ -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);
+5
View File
@@ -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) {