package github // profileQuery pulls everything needed for the profile, stats and languages // cards in one round trip. Fork/private filtering is done client-side so one // query handles all combinations of -include-forks / -include-private. const profileQuery = ` query($login: String!, $after: String) { user(login: $login) { id login name bio avatarUrl company location websiteUrl createdAt followers { totalCount } following { totalCount } pullRequests { totalCount } issues { totalCount } repositoriesContributedTo( first: 1 contributionTypes: [COMMIT, PULL_REQUEST, ISSUE, PULL_REQUEST_REVIEW] ) { totalCount } contributionsCollection { contributionYears totalCommitContributions totalIssueContributions totalPullRequestContributions totalPullRequestReviewContributions totalRepositoryContributions restrictedContributionsCount contributionCalendar { totalContributions weeks { contributionDays { contributionCount date } } } } repositories( first: 100 after: $after ownerAffiliations: OWNER orderBy: { field: STARGAZERS, direction: DESC } ) { totalCount pageInfo { hasNextPage endCursor } nodes { name isPrivate isFork stargazerCount forkCount primaryLanguage { name color } languages(first: 20, orderBy: { field: SIZE, direction: DESC }) { edges { size node { name color } } } } } } }` // commitHistoryQuery fetches commit timestamps in the default branch of one // repo, filtered to commits authored by the target user. Used to build the // productive-time heatmap. Owner is a variable because seed repos may belong // to other users (e.g. forks the user has contributed to). const commitHistoryQuery = ` query($owner: String!, $repo: String!, $userId: ID!, $after: String) { repository(owner: $owner, name: $repo) { defaultBranchRef { target { ... on Commit { history(first: 100, after: $after, author: { id: $userId }) { pageInfo { hasNextPage endCursor } nodes { committedDate } } } } } } }` // contributionYearQuery fetches one year's contribution calendar plus the // repos the user actually committed in that year. The calendar feeds the // all-time area chart; commitContributionsByRepository feeds the seed list // that drives commit-history probing. const contributionYearQuery = ` query($login: String!, $from: DateTime!, $to: DateTime!) { user(login: $login) { contributionsCollection(from: $from, to: $to) { totalCommitContributions contributionCalendar { weeks { contributionDays { contributionCount date } } } commitContributionsByRepository(maxRepositories: 100) { contributions { totalCount } repository { name owner { login } isPrivate isFork primaryLanguage { name color } languages(first: 20, orderBy: { field: SIZE, direction: DESC }) { edges { size node { name color } } } } } } } }`