-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Migrate list_issues tool from REST to GraphQL API #833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the list_issues
tool from GitHub's REST API to GraphQL API to improve performance and provide more efficient data fetching capabilities.
- Replaced REST API client with GraphQL client for issue listing functionality
- Implemented conditional GraphQL query structures based on label filtering requirements
- Migrated from page-based to cursor-based pagination with improved user guidance
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
File | Description |
---|---|
pkg/github/tools.go | Updated tool registration to use GraphQL client instead of REST client |
pkg/github/queries.json | Added sample GraphQL response data and mock JSON structures |
pkg/github/issues.go | Complete migration of list_issues implementation from REST to GraphQL with new data structures and pagination |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Migrate
list_issues
tool from REST to GraphQL APIOverview
The key requirement was to ignore PRs when the
list_issues
tool was used. As per #790. To accomplish this, the tool had to be migrated away from the REST API, as this was not an allowed request. Therefore this PR migrates thelist_issues
tool from GitHub's REST API to GraphQL API, bringing it in line with other tools likelist_discussions
. The migration provides cursor-based pagination, improved filtering, and better performance.Key Changes
github.Client
(REST) togithubv4.Client
(GraphQL)after
,perPage
)since
parameter for date filtering (ISO 8601 format)GraphQL vs REST
Parameter Updates:
page
→after
(cursor-based pagination)sort
→orderBy
with new enum values"open"
→"OPEN"
,"closed"
→"CLOSED"
"asc"
→"ASC"
,"desc"
→"DESC"
"created"
→"CREATED_AT"
,"updated"
→"UPDATED_AT"
Implementation
Dynamic Query Selection: Factory pattern selects appropriate GraphQL query based on filtering requirements (4 query types: base, with labels, with since, with both).
Fragment Architecture: Reusable
IssueFragment
with common interface for consistent data conversion.Testing & Quality
githubv4mock
This migration provides better performance, consistent API patterns, and enhanced filtering while maintaining backward compatibility. 🚀
Before & After
Before: Returns correct info (but included PRs) and lots of URLs.
[ { "id": 1234567890, "number": 842, "state": "open", "locked": false, "title": "[sanitized] Tool reports success when a non-existent repo owner is used", "body": "[sanitized] Bug description with reproduction steps...", "author_association": "NONE", "user": { "login": "[username]", "id": 12345678, "node_id": "[sanitized_node_id]", "avatar_url": "[sanitized_avatar_url]", "html_url": "[sanitized_profile_url]", "gravatar_id": "", "type": "User", "site_admin": false, "url": "[sanitized_api_url]", "events_url": "[sanitized_events_url]", "following_url": "[sanitized_following_url]", "followers_url": "[sanitized_followers_url]", "gists_url": "[sanitized_gists_url]", "organizations_url": "[sanitized_orgs_url]", "received_events_url": "[sanitized_received_events_url]", "repos_url": "[sanitized_repos_url]", "starred_url": "[sanitized_starred_url]", "subscriptions_url": "[sanitized_subscriptions_url]" }, "labels": [ { "id": 1234567890, "url": "[sanitized_label_url]", "name": "bug", "color": "d73a4a", "description": "Something isn't working", "default": true, "node_id": "[sanitized_node_id]" } ], "comments": 0, "created_at": "2025-08-08T02:29:19Z", "updated_at": "2025-08-08T07:32:39Z", "url": "[sanitized_api_url]", "html_url": "[sanitized_web_url]", "comments_url": "[sanitized_comments_url]", "events_url": "[sanitized_events_url]", "labels_url": "[sanitized_labels_url]", "repository_url": "[sanitized_repo_url]", "reactions": { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "confused": 0, "heart": 0, "hooray": 0, "rocket": 0, "eyes": 0, "url": "[sanitized_reactions_url]" }, "node_id": "[sanitized_node_id]" } ]
After: Reduction in context, avoiding unnecessary URLs, irrelevant data and does not return PRs.
{ "issues": [ { "id": 1234567890, "number": 1234, "state": "OPEN", "title": "[sanitized] Sample issue title", "body": "[sanitized] Issue description and reproduction steps...", "user": { "login": "[username]" }, "labels": [ { "name": "bug", "description": "Something isn't working", "node_id": "[sanitized_node_id]" } ], "created_at": "2025-08-07T17:21:22Z", "updated_at": "2025-08-07T17:21:22Z" } ], "pageInfo": { "endCursor": "[base64_cursor]", "hasNextPage": true, "hasPreviousPage": false, "startCursor": "[base64_cursor]" }, "totalCount": 622 }