shurcooL / githubv4

Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql).
MIT License
1.1k stars 89 forks source link

Adding RetryAfter to the error message to handle retry situation #96

Closed jmguzik closed 2 years ago

jmguzik commented 2 years ago

Hi @dmitshur, would you accept the PR that would add to the error messages RetryAfter from header? Github tells in response how many seconds one must wait to query again (eg: in case of 403 -> secondary rate limit exceeded). We have implemented a mechanism of retrying for APIv3. We would like to have similar for v4.

I may missed something, but if similar mechanism already exists and I can "get" to the message, please let me know. Thanks!

dmitshur commented 2 years ago

I know this is documented for GitHub REST API (v3) at https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits and https://docs.github.com/en/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits.

Do you know if this is documented for GitHub GraphQL API (v4) as well, somewhere at https://docs.github.com/en/graphql? I'm only finding https://docs.github.com/en/graphql/overview/resource-limitations, and no mention of Retry-After header there.

jmguzik commented 2 years ago

I have checked this myself and for several API 4 messages it was always there. It would be nice to have that but I found a workaround, a round tripper modification with a decorator is good enough to have this done.