Skip to content

fix: split stats query to fit GitHub GraphQL per-query resource limits (RESOURCE_LIMITS_EXCEEDED) - #4918

Closed
luojiyin1987 wants to merge 13 commits into
anuraghazra:masterfrom
luojiyin1987:fix/graphql-resource-limits
Closed

fix: split stats query to fit GitHub GraphQL per-query resource limits (RESOURCE_LIMITS_EXCEEDED)#4918
luojiyin1987 wants to merge 13 commits into
anuraghazra:masterfrom
luojiyin1987:fix/graphql-resource-limits

Conversation

@luojiyin1987

Copy link
Copy Markdown

Problem

Since GitHub tightened its GraphQL per-query resource budget, the combined GRAPHQL_STATS_QUERY exceeds it and every /api stats card fails with:

Resource limits for this query exceeded.

The error path points at whichever field exhausts the budget, making it look field-specific; probing shows the limit is cumulative.

Fix

  • Merge the commits: / reviews: aliases into a single contributions: contributionsCollection selection.
  • Split the stats fetch into three requests, each within the budget:
    1. contribution + count stats (GRAPHQL_STATS_QUERY, no repositories field),
    2. repositories via the paginated GRAPHQL_REPOS_QUERY,
    3. repositoriesContributedTo on its own (GRAPHQL_CONTRIBUTED_TO_QUERY).

Trade-offs

  • Up to 2 extra GraphQL requests per uncached render.
  • When commits_year is set, totalPullRequestReviewContributions is now scoped to the same from: window as commits (both live in one collection).

Tests

  • Fixtures mirror per-query API responses; mock router in fetchStats.test.js dispatches on query content.
  • faker() in api.test.js switched from replyOnce to reply (three GraphQL calls now).
  • Added missing await on two floating rejects assertions in fetchStats.test.js.

npm run lint and prettier --check clean; stats/api/bench test suites pass.

Cherry-pick of upstream PR #4916.

🤖 Generated with Claude Code

Signed-off-by: luojiyin <luojiyin@hotmail.com>
GitHub's GraphQL API now enforces a per-query resource budget that the
combined stats query exceeds, causing every stats card to fail with
RESOURCE_LIMITS_EXCEEDED. Merge the two aliased contributionsCollection
selections into one, and split the stats fetch into three requests within
the budget: contribution/count stats, paginated repositories, and
repositoriesContributedTo. Adapt test fixtures to the per-query responses.
@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

@luojiyin1987 is attempting to deploy a commit to the github readme stats Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added documentation Improvements or additions to documentation. stats-card Feature, Enhancement, Fixes related to stats the stats card. ci CI related features. labels Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI related features. documentation Improvements or additions to documentation. stats-card Feature, Enhancement, Fixes related to stats the stats card.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant