Skip to content

perf(api): migrate to GitHub GraphQL API to reduce rate limit issues - #20

Merged
taiiiyang merged 1 commit into
mainfrom
feat/graphql-api-migration
Mar 9, 2026
Merged

perf(api): migrate to GitHub GraphQL API to reduce rate limit issues#20
taiiiyang merged 1 commit into
mainfrom
feat/graphql-api-migration

Conversation

@taiiiyang

Copy link
Copy Markdown
Owner

Type of Changes

  • ✨ New feature (feat)
  • 🐛 Bug fix (fix)
  • 📝 Documentation change (docs)
  • 💄 UI/style change (style)
  • ♻️ Code refactoring (refactor)
  • ⚡ Performance improvement (perf)
  • ✅ Test related (test)
  • 🔧 Build or dependencies update (build)
  • 🔄 CI/CD related (ci)
  • 🌐 Internationalization (i18n)
  • 🧠 AI model related (ai)
  • 🔄 Revert a previous commit (revert)
  • 📦 Other changes that do not modify src or test files (chore)

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)
  • Total: 8 requests → 2 requests per PR page load

Without token (REST fallback):

  • Merged totalPRs and firstContributionAt into a single searchIssues call (same query, different sort)
  • Total: 8 requests → 7 requests per PR page load

Key implementation details

  • New githubGraphQL() helper with proper bearer token auth and GraphQL error handling
  • Replaced searchCount() with searchIssues() that returns { total_count, items } for richer data extraction
  • GraphQL rate limit: 5000 points/hour (~1 point per query) vs REST Search: 30 req/min
  • No interface changes — RepoContribution and GlobalContribution types unchanged

Related Issue

Rate limit complaints from users with PAT tokens configured.

How Has This Been Tested?

  • Verified through manual testing
  • pnpm lint passes
  • pnpm tsc --noEmit passes
  • pnpm build passes (via pre-push hook)

Checklist

  • I have tested these changes locally
  • I have updated the documentation accordingly if necessary
  • My code follows the code style of this project
  • My changes do not break existing functionality
  • If my code was generated by AI, I have proofread and improved it as necessary.

Additional Information

  • Only src/lib/github-rest.ts was modified — no changes to atoms, components, or other files
  • GraphQL requires authentication, so unauthenticated users automatically use the REST fallback path

🤖 Generated with Claude Code

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>
@github-actions github-actions Bot added the perf label Mar 9, 2026
@taiiiyang
taiiiyang merged commit 1e4b6bc into main Mar 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant