Skip to content

Commit

Permalink
Add default affiliation
Browse files Browse the repository at this point in the history
  • Loading branch information
developStorm committed Dec 4, 2021
1 parent f19d94f commit dfc44b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/fetchers/stats-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/fetchers/top-languages-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit dfc44b6

Please sign in to comment.