octokit.graphql.net
octokit.graphql.net copied to clipboard
Support automatically getting rate limit information during a query
When I was doing GitHub GraphQL queries manually, I would almost always write them like this:
query {
rateLimit {
cost
remaining
resetAt
}
// The rest of my query ...
}
That way, I could load the rate limit information directly without having to make separate queries to get it. Plus, every query would include the cost so that I could track that in my application. As far as I can tell, this is not possible in Octokit.GraphQL.Net. I think it would be a very valuable addition.
Ideally, I'd be able to add some configuration option in my query to indicate I want rate limit data (a boolean constructor arg on Query or an extension method of some kind) and the return value of the query would be augmented to be something like QueryResult<T> which exposes T as a property, as well as the rate limit data:
var query = new Query()
.WithRateLimit(/* options like which rate limit fields to include */)
.Repository(...)
// The rest of my query...
var results = await _connection.Run(query);
Console.WriteLine($"Rate Limit cost: {results.RateLimit.Cost}");
Console.WriteLine($"Results: {results.Data}"); // <-- The actual data returned by the query
As far as I can tell, without a feature like this, it's not really possible to get the "cost" of a GraphQL query, since that field only really works when attached to a query. I can only make separate queries for my remaining rate limit and the reset time.
👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!