Skip to content

Support for specifying the desired GitHub projects #10

@MathyouMB

Description

@MathyouMB

As a developer, I want to specify which GitHub ProjectV2 board reminders should query from, so that we can support multiple projects in the future.


🧠 Context

Currently, the projectV2Items GraphQL query hardcodes the project number to 18:

  • See: src/github/graphql/projectV2Items.ts

Hardcoded project number

This means reminder logic is tightly coupled to a single project board. To support multiple GitHub projects (e.g. for different teams, terms, or categories), we need to pass in the project number dynamically via query variables.

The query is executed in
src/infrastructure/github/functions/fetchProjectItems.ts.
We want to be able to pass in a project ID from this function so that reminders can be scoped per project.

There is no need to install a new GraphQL client — we already support query variables elsewhere in the codebase.
See src/infrastructure/github/functions/updateProjectItemAssignee.ts for an example of how variables are passed.


🛠️ Implementation Plan

  1. Move Default Project Number to a Constant

    • Create a constant named DEFAULT_PROJECT_NUMBER in src/infrastructure/github/constants.ts:

      export const DEFAULT_PROJECT_NUMBER = 18;
  2. Update the GraphQL Query

    • In src/github/graphql/projectV2Items.ts, replace the hardcoded number: 18 with a $projectNumber variable
    • Declare $projectNumber in the query’s variable block and use it in the projectV2(number: $projectNumber) field
  3. Update Query Invocation

    • In fetchProjectItems.ts, accept a projectNumber parameter (with a fallback to DEFAULT_PROJECT_NUMBER)

    • Inject this variable into the GraphQL request:

      const response = await axios.post(
        "https://api.github.com/graphql",
        {
          query: PROJECT_V2_ITEMS,
          variables: {
            projectNumber: projectNumber ?? DEFAULT_PROJECT_NUMBER,
          },
        },
        { headers: { Authorization: `Bearer ${TOKEN}` } }
      );
  4. Follow Existing Patterns

    • Refer to updateProjectItemAssignee.ts for how query variables are structured and passed into the request body
  5. Write Tests

    • Write unit tests for fetchProjectItems to confirm it supports variable input
    • Use a mock query to verify the correct value is passed into the request body

✅ Acceptance Criteria

  • DEFAULT_PROJECT_NUMBER is defined in src/infrastructure/github/constants.ts
  • projectV2Items query in src/github/graphql/projectV2Items.ts uses a $projectNumber variable instead of hardcoding 18
  • fetchProjectItems.ts accepts a projectNumber parameter and injects it into the GraphQL request, defaulting to DEFAULT_PROJECT_NUMBER
  • A unit test verifies that projectNumber can be dynamically passed into fetchProjectItems
  • Reminder logic is no longer tied to a single project board

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