Skip to content

Remove the rateLimit selection from the MaxPullRequest GraphQL query#8812

Merged
alexr00 merged 3 commits into
microsoft:mainfrom
kamil-gwozdz:kamil-gwozdz/maxpullrequest-drop-ratelimit
Jul 2, 2026
Merged

Remove the rateLimit selection from the MaxPullRequest GraphQL query#8812
alexr00 merged 3 commits into
microsoft:mainfrom
kamil-gwozdz:kamil-gwozdz/maxpullrequest-drop-ratelimit

Conversation

@kamil-gwozdz

@kamil-gwozdz kamil-gwozdz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

MaxPullRequest represents a big chunk of our graphql traffic volume and we're currently trying to optimize it.

The rateLimit portion is only used by LoggingApolloClient.query which is a high level client and it's never read by the query actual caller - _getMaxItem - shared by both MaxIssue and MaxPullRequest - returns only number. It never reads data.rateLimit.

Since other queries are requesting this field the global store should be fine and updated on any other occasion.


🤖 AI-generated description

What changed

This PR removes the top-level rateLimit { ...RateLimit } selection from the MaxPullRequest query in src/github/queriesShared.gql. No other queries are touched — MaxIssue and the ~28 other operations that select rateLimit keep it, and the shared fragment RateLimit on RateLimit remains in use elsewhere, so it stays defined.

Why

MaxPullRequest is a high-frequency, per-repo change-detection poll — one of the hottest GraphQL operations the extension emits. Its handler _getMaxItem (src/github/githubRepository.ts) reads only data.repository.issues.edges[0].node.number (the latest PR number) and never touches data.rateLimit. Selecting rateLimit on every poll asks the GitHub GraphQL API to resolve an extra top-level field whose result is discarded. Dropping it trims that unused resolver from the highest-volume query.

Scope & safety

  • No functional impact. The only generic consumer of the field is RateLogger.logRateLimit (src/github/loggingOctokit.ts), invoked by the LoggingApolloClient.query wrapper on every query. It reads resolvedResult?.data?.rateLimit and already degrades gracefully when the field is absent: it falls back to ?? 5000 / ?? 1000 defaults. As a result, removing the selection produces no spurious "Unexpectedly low rate limit" warning, and the pr.lowRateLimitRemaining telemetry simply does not fire for this single call path.
  • Rate-limit visibility is preserved. Every other query that selects rateLimit continues to report it, so overall rate-limit monitoring and telemetry are unaffected.
  • No type changes needed. _getMaxItem does not reference rateLimit, and the MaxIssueResponse interface still applies to MaxIssue. The .gql files are loaded at build time via the graphql-tag webpack loader; there is no committed generated TypeScript to regenerate.

Notes

  • The change is intentionally surgical: MaxPullRequest only, leaving MaxIssue and all other rateLimit-selecting queries as-is.
  • Because logRateLimit already handles the missing-field case, this is a safe no-op for behavior — it only reduces what MaxPullRequest asks the API to resolve.

MaxPullRequest is a very high-frequency change-detection poll, and its
handler (_getMaxItem) only reads the latest PR number — it never consumes
the rateLimit block. The only generic consumer (RateLogger.logRateLimit)
already degrades gracefully when rateLimit is absent (it falls back to the
?? 5000 / ?? 1000 defaults and other queries still report it), so removing
this top-level field from the hottest query has no functional impact.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kamil-gwozdz kamil-gwozdz changed the title Drop unused rateLimit selection from the MaxPullRequest query Remove the unused rateLimit selection from the MaxPullRequest GraphQL query Jun 25, 2026
@alexr00

alexr00 commented Jun 26, 2026

Copy link
Copy Markdown
Member

This is used.

@alexr00 alexr00 closed this Jun 26, 2026
@alexr00 alexr00 reopened this Jul 2, 2026
@alexr00 alexr00 changed the title Remove the unused rateLimit selection from the MaxPullRequest GraphQL query Remove the noisy rateLimit selection from the MaxPullRequest GraphQL query Jul 2, 2026
@kamil-gwozdz kamil-gwozdz changed the title Remove the noisy rateLimit selection from the MaxPullRequest GraphQL query Remove the rateLimit selection from the MaxPullRequest GraphQL query Jul 2, 2026
@kamil-gwozdz kamil-gwozdz marked this pull request as ready for review July 2, 2026 09:57
Copilot AI review requested due to automatic review settings July 2, 2026 09:57
@alexr00 alexr00 added this to the 1.128.0 milestone Jul 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces GraphQL payload/field resolution work for one of the extension’s highest-volume operations (MaxPullRequest) by removing an unused top-level rateLimit { ...RateLimit } selection that the actual caller (_getMaxItem) never reads.

Changes:

  • Remove the rateLimit { ...RateLimit } selection from the MaxPullRequest GraphQL query to avoid requesting unused data on a hot polling path.
Show a summary per file
File Description
src/github/queriesShared.gql Removes the unused rateLimit selection from the MaxPullRequest query to reduce per-request overhead.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Low

Copilot AI review requested due to automatic review settings July 2, 2026 10:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread src/github/queriesShared.gql
@alexr00 alexr00 enabled auto-merge (squash) July 2, 2026 10:06
@alexr00

alexr00 commented Jul 2, 2026

Copy link
Copy Markdown
Member

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@alexr00 alexr00 merged commit 4209543 into microsoft:main Jul 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants