octokit / octokit.graphql.net

A GitHub GraphQL client library for .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include Rate Limit status data in query result output

tedvanderveen opened this issue · comments

When querying the GitHub v4 GraphQL endpoint, the response contains HTTP headers that indicate the current Rate Limit status:

X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
X-RateLimit-Reset: 1576224622

This information is currently ignored, but I need it to pro-actively avoid running into 429 responses and have my toolset take a break before sending the next request.

Maybe the most simple solution is to use the great Polly library and setup a WaitAndRetryAsync retry policy that handles 429 responses from the Github API and respects the X-RateLimit-Reset HTTP header?
See also https://github.com/App-vNext/Polly/blob/9c133b6303ca70d2879fddf16fb201c209eb6fd2/src/Polly.Shared/Retry/RetryTResultSyntaxAsync.cs#L615