Skip to content

Request additional GitHub "projectV2Items" via pagination #1

@MathyouMB

Description

@MathyouMB

As a developer, I want to ensure all GitHub ProjectV2 items are fetched—even when there are more than 100—so that reminder tasks always include the full list of project items.


🧠 Context

GitHub's GraphQL API has a pagination limit of 100 items per request when querying projectV2Items. This is fine for now since our project has fewer than 100 items, but we will eventually exceed this limit. If we don’t handle pagination, some project items will be excluded from reminder logic.

Currently, we fire the query in
src/infrastructure/github/functions/fetchProjectItems.ts,
which uses the GraphQL document defined in
src/github/graphql/projectV2Items.ts.

The GraphQL response includes a pageInfo.hasNextPage field, which indicates whether more items are available.

To support pagination:

  • If hasNextPage is true, we should fire additional requests to fetch the remaining items.
  • This should repeat until hasNextPage is false.

To paginate properly, we need to update our GraphQL query to use the after parameter (and optionally before), in addition to the first parameter (currently defined on line 5):

GraphQL Pagination Screenshot

There’s no need to introduce a new GraphQL client—existing examples of how to pass query variables can be found in
src/infrastructure/github/functions/updateProjectItemAssignee.ts.


🛠️ Implementation Plan

  1. Update the GraphQL Query

    • Modify src/github/graphql/projectV2Items.ts to accept and use an after variable in the projectV2Items connection
  2. Implement Pagination Logic

    • In src/infrastructure/github/functions/fetchProjectItems.ts, update the logic to:

      • Track the endCursor returned from each page
      • Use hasNextPage to continue fetching pages
      • Accumulate all items across pages into a single array
  3. Follow Existing Variable Patterns

    • Refer to src/infrastructure/github/functions/updateProjectItemAssignee.ts for how to pass variables into GraphQL queries with our current setup
  4. Write Tests

    • Mock paginated GraphQL responses
    • Verify that multiple pages are fetched and merged correctly
    • Ensure all items are returned even when more than 100 exist

✅ Acceptance Criteria

  • projectV2Items query in src/github/graphql/projectV2Items.ts uses the after parameter to support pagination
  • Logic in fetchProjectItems.ts handles pagination using hasNextPage and endCursor
  • No new GraphQL client is introduced; variable handling follows existing code patterns
  • Pagination logic is tested using mocked GraphQL responses
  • All project items are fetched and included in reminders, even when the count exceeds 100

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Ready

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions