Add GraphQL pagination via @octokit/plugin-paginate-graphql - #729
Open
KR-Ravindra wants to merge 1 commit into
Open
Add GraphQL pagination via @octokit/plugin-paginate-graphql#729KR-Ravindra wants to merge 1 commit into
KR-Ravindra wants to merge 1 commit into
Conversation
Include the paginate-graphql Octokit plugin by default so scripts can call github.graphql.paginate / github.graphql.paginate.iterator instead of hand-rolling cursor loops, mirroring github.paginate for REST. The plugin is added to both the pre-built github client and the secondary clients created through the injected getOctokit. Adds a README example, a licensed cache entry, an integration job, and rebuilds dist/. Refs actions#309
Author
|
Round 1 self-review.
Marking ready; all workflows are waiting on first-contributor approval. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
github.paginatehandles REST pagination, but scripts that page GraphQL results still have to hand-roll cursor loops. #309 asks to include@octokit/plugin-paginate-graphqlby default sogithub.graphql.paginateworks like the REST helper does.Fix
@octokit/plugin-paginate-graphql^6.0.0(peer@octokit/core >=6, compatible with the v7 core already in use) as a dependency.src/main.tsaddspaginateGraphQLto the plugin list of both the pre-builtgithubclient andcreateConfiguredGetOctokit, so secondary clients from the injectedgetOctokitalso getgraphql.paginate/graphql.paginate.iterator..licenses/cache entry for the new package (as done forplugin-request-log);dist/rebuilt withnpm run build.How tested
__test__/main.test.tsloadssrc/main.tswith inputs set throughINPUT_*env vars and stand-ins for the ESM-only@actions/github/ Octokit plugin packages (the CommonJS Jest runtime cannot load them, which is why the existing tests avoid them too). It asserts the primary client and a secondarygetOctokitclient are both built withretry, requestLog, paginateGraphQL.main.ts): both assertions fail,getOctokitreceived onlyretry, requestLog.npm run style:checkclean.integration.ymljobtest-graphql-paginatewalks two pages of issues withgithub.graphql.paginate.iteratoragainst the real API and checks bothgithuband agetOctokitsecondary client exposegraphql.paginate.dist/index.jslocally with a dummy token:typeof github.graphql.paginateandtypeof getOctokit('t').graphql.paginateboth returnfunction; the previous build fails withCannot read properties of undefined (reading 'iterator').Links
This change was prepared with an AI agent operated by KR-Ravindra, who reviewed and tested it.