perf(api): migrate to GitHub GraphQL API to reduce rate limit issues - #20
Merged
Conversation
Replace 7 REST Search API calls with 2 GraphQL queries when PAT token is available, avoiding the 30 req/min Search API rate limit. Falls back to REST for unauthenticated users (with 1 fewer call via merged query). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Changes
Description
Migrate from GitHub REST Search API to GraphQL API to solve rate limit issues. The REST Search API has a strict 30 requests/minute limit (even with PAT), and the extension was making 7 Search API calls per PR page load, causing users to hit the limit after browsing just 4-5 PRs.
Changes
With PAT token (GraphQL path):
fetchRepoContribution: 3-4 REST Search calls → 1 GraphQL query (repo merged PRs, total PRs, reviews, firstContributionAt)fetchGlobalContribution: 3 REST Search + 1 REST user call → 1 GraphQL query (user profile + global merged PRs, total PRs, reviews)Without token (REST fallback):
totalPRsandfirstContributionAtinto a singlesearchIssuescall (same query, different sort)Key implementation details
githubGraphQL()helper with properbearertoken auth and GraphQL error handlingsearchCount()withsearchIssues()that returns{ total_count, items }for richer data extractionRepoContributionandGlobalContributiontypes unchangedRelated Issue
Rate limit complaints from users with PAT tokens configured.
How Has This Been Tested?
pnpm lintpassespnpm tsc --noEmitpassespnpm buildpasses (via pre-push hook)Checklist
Additional Information
src/lib/github-rest.tswas modified — no changes to atoms, components, or other files🤖 Generated with Claude Code