Skip to content

Comments

Use GraphQL for fetching GitHub Pull Requests#85

Merged
Malcolmnixon merged 2 commits intomainfrom
copilot/use-graphql-for-pull-requests
Feb 17, 2026
Merged

Use GraphQL for fetching GitHub Pull Requests#85
Malcolmnixon merged 2 commits intomainfrom
copilot/use-graphql-for-pull-requests

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Pull Request

Description

Replaces Octokit REST API PullRequest.GetAllForRepository with GraphQL to continue Octokit removal.

Core Changes:

  • GraphQL Types (GitHubGraphQLTypes.cs): Added PullRequestNode, PullRequestMergeCommit, PullRequestLabel with pagination support
  • Client Method (GitHubGraphQLClient.cs): Implemented GetPullRequestsAsync with cursor-based pagination (100 items/page), null-safe filtering
  • Internal Types (GitHubRepoConnector.cs): Created PullRequestInfo wrapper to eliminate Octokit dependency, added GetAllPullRequestsAsync adapter method
  • Tests (GitHubGraphQLClientGetPullRequestsTests.cs): 8 test cases covering valid responses, empty results, null data, HTTP errors, invalid JSON, pagination

GraphQL Query Structure:

query($owner: String!, $repo: String!, $after: String) {
  repository(owner: $owner, name: $repo) {
    pullRequests(first: 100, after: $after) {
      nodes {
        number, title, url, merged
        mergeCommit { oid }
        headRefOid
        labels(first: 100) { nodes { name } }
      }
      pageInfo { hasNextPage, endCursor }
    }
  }
}

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code quality improvement

Related Issues

Addresses feature request for GraphQL-based pull request fetching.

Pre-Submission Checklist

Before submitting this pull request, ensure you have completed the following:

Build and Test

  • Code builds successfully: dotnet build --configuration Release
  • All tests pass: dotnet test --configuration Release
  • Code produces zero warnings

Code Quality

  • Code formatting is correct: dotnet format --verify-no-changes
  • New code has appropriate XML documentation comments
  • Static analyzer warnings have been addressed

Quality Checks

Please run the following checks before submitting:

  • Spell checker passes: cspell "**/*.{md,cs}"
  • Markdown linter passes: markdownlint "**/*.md"
  • YAML linter passes: yamllint '**/*.{yml,yaml}'

Testing

  • Added unit tests for new functionality
  • Updated existing tests if behavior changed
  • All tests follow the AAA (Arrange, Act, Assert) pattern
  • Test coverage is maintained or improved

Documentation

  • Updated README.md (if applicable)
  • Updated ARCHITECTURE.md (if applicable)
  • Added code examples for new features (if applicable)
  • Updated requirements.yaml (if applicable)

Additional Notes

Test Results:

  • 8/8 new GraphQL tests pass
  • 162/163 existing tests pass (1 DNS-related failure unrelated to changes)
  • 4/4 self-validation tests pass
  • CodeQL: 0 alerts

Architecture: Follows existing patterns for GraphQL methods (GetCommitsAsync, GetReleasesAsync). Internal wrapper types isolate Octokit dependencies for future removal.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net9.0/DemaConsulting.BuildMark.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net9.0/DemaConsulting.BuildMark.Tests.deps.json /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net9.0/testhost.dll --port 39773 --endpoint 127.0.0.1:039773 --role client --parentprocessid 5206 --telemetryoptedin false (http block)
  • https://api.github.com/repos/demaconsulting/BuildMark/issues
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net9.0/DemaConsulting.BuildMark.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net9.0/DemaConsulting.BuildMark.Tests.deps.json /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net9.0/testhost.dll --port 39773 --endpoint 127.0.0.1:039773 --role client --parentprocessid 5206 --telemetryoptedin false (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: Use GraphQL for fetching GitHub Pull Requests</issue_title>
<issue_description>### Problem Statement

The Octokit client.PullRequest.GetAllForRepository needs to be replaced with GraphQL

Proposed Solution

Replace the client.PullRequest.GetAllForRepository calls with a call to a new GitHubGraphQLClient.GetPullRequests which uses GraphQL. Note that the Octokit query uses State = ItemStateFilter.All to get pull requests in any state (open, closed, etc.) and the GraphQL can just hard-code the query to get all.
The new GraphQL records can be created in GitHubGraphQLTypes.cs
The new tests should be implemented in a GitHubGraphQLClientGetPullRequestsTests.cs file

Alternatives Considered

No response

Usage Examples

Benefits

More removal of Octokit usage.

Priority

Medium - Would improve my workflow

Willingness to Contribute

Yes, I can submit a pull request

Additional Context

No response

Checklist

  • I have searched existing issues to ensure this is not a duplicate
  • I have provided a clear description of the feature
  • I have explained why this feature would be useful</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Add PullRequestNode and related GraphQL types
- Implement GetPullRequestsAsync in GitHubGraphQLClient
- Create comprehensive tests for GetPullRequestsAsync
- Add PullRequestInfo internal type to replace Octokit.PullRequest
- Update GitHubRepoConnector to use GraphQL for pull requests
- Replace Octokit PullRequest.GetAllForRepository with GraphQL

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Copilot AI changed the title [WIP] Use GraphQL for fetching GitHub pull requests Use GraphQL for fetching GitHub Pull Requests Feb 17, 2026
Copilot AI requested a review from Malcolmnixon February 17, 2026 14:33
@Malcolmnixon Malcolmnixon marked this pull request as ready for review February 17, 2026 14:47
@Malcolmnixon Malcolmnixon merged commit d9fdd8e into main Feb 17, 2026
11 checks passed
@Malcolmnixon Malcolmnixon deleted the copilot/use-graphql-for-pull-requests branch February 17, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Use GraphQL for fetching GitHub Pull Requests

2 participants