yanyongyu / githubkit

The modern, all-batteries-included GitHub SDK for Python, including rest api, graphql, webhooks, like octokit!
https://yanyongyu.github.io/githubkit/
MIT License
204 stars 25 forks source link

Feature: add graphql pagination support #121

Closed yanyongyu closed 4 months ago

yanyongyu commented 4 months ago

resolve #112

Example usage

from githubkit import GitHub

g = GitHub("your token here")

query = """
query($owner:String!, $repo: String!, $cursor: String) {
  repository(owner:$owner, name:$repo) {
    issues(first: 10, after: $cursor) {
      nodes {
        number
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }
}
"""

for result in g.graphql.paginate(query, {"owner": "owner", "repo": "repo"}):
    for issue in result["repository"]["issues"]["nodes"]:
        print(issue)
codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 91.81818% with 9 lines in your changes missing coverage. Please review.

Project coverage is 17.64%. Comparing base (a90820a) to head (0e080c6).

Files Patch % Lines
githubkit/graphql/__init__.py 89.18% 4 Missing :warning:
githubkit/graphql/paginator.py 93.44% 4 Missing :warning:
githubkit/exception.py 85.71% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #121 +/- ## ========================================== + Coverage 17.61% 17.64% +0.03% ========================================== Files 4791 4792 +1 Lines 222451 222542 +91 ========================================== + Hits 39191 39276 +85 - Misses 183260 183266 +6 ``` | [Flag](https://app.codecov.io/gh/yanyongyu/githubkit/pull/121/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ju4tCode) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/yanyongyu/githubkit/pull/121/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ju4tCode) | `17.64% <91.81%> (+0.03%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ju4tCode#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.