Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kerobbi merged 14 commits intomainfromfix-790-separate-issues-from-prs
Aug 8, 2025

Conversation

MattBabbage
Copy link
Contributor

@MattBabbageMattBabbage commentedAug 7, 2025
edited
Loading

Migratelist_issues tool from REST to GraphQL API

Overview

The key requirement was to ignore PRs when thelist_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

  • API Migration: Switched fromgithub.Client (REST) togithubv4.Client (GraphQL)
  • Pagination: Migrated from page-based to cursor-based (after,perPage)
  • Dynamic Queries: Conditional GraphQL queries based on labels and date filtering
  • New Features: Addedsince parameter for date filtering (ISO 8601 format)
  • Enhanced Performance: GraphQL's selective field querying reduces payload size

GraphQL vs REST

Parameter Updates:

  • pageafter (cursor-based pagination)
  • sortorderBy with new enum values
  • State values:"open""OPEN","closed""CLOSED"
  • Direction values:"asc""ASC","desc""DESC"
  • Order fields:"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: ReusableIssueFragment with common interface for consistent data conversion.

Testing & Quality

  • Updated tests to use GraphQL mocking withgithubv4mock
  • Comprehensive coverage: tool definition, dynamic queries, fragment conversion
  • Updated README.md with new parameter descriptions
  • All linting checks pass

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 }

LuluBeatson reacted with rocket emoji
@MattBabbageMattBabbage requested a review froma team as acode ownerAugust 7, 2025 10:36
@CopilotCopilotAI review requested due to automatic review settingsAugust 7, 2025 10:36
Copy link
Contributor

@CopilotCopilotAI left a 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 thelist_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.

FileDescription
pkg/github/tools.goUpdated tool registration to use GraphQL client instead of REST client
pkg/github/queries.jsonAdded sample GraphQL response data and mock JSON structures
pkg/github/issues.goComplete migration of list_issues implementation from REST to GraphQL with new data structures and pagination

@MattBabbageMattBabbage linked an issueAug 8, 2025 that may beclosed by this pull request
Copy link
Contributor

@kerobbikerobbi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM!

@kerobbikerobbi merged commit8aa3379 intomainAug 8, 2025
16 checks passed
@kerobbikerobbi deleted the fix-790-separate-issues-from-prs branchAugust 8, 2025 14:26
nickytonline pushed a commit to nickytonline/github-mcp-http that referenced this pull requestOct 4, 2025
* initial changes* Further advances on list_issues tool to use GRPC* Updating pagination for Graphql ListIssues* Sorting data structures & returning mapped Issue* Adding dynamic label queries* Adding dynamic state queries for list_issues* Add optional since filter, to get issues based on last update to issue* Move ListIssues test to graphql format & removal of temp file* Update documentation and fix linter issues* Removal of redundant code, and increase limit on label return* Fixing context for status to allow for better interactions* Update tool snaps with tool description* Update docs for final changes to context
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tommaso-morotommaso-morotommaso-moro left review comments

Copilot code reviewCopilotCopilot left review comments

@kerobbikerobbikerobbi approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Provide a top level function for fetching non-PR issues
3 participants
@MattBabbage@tommaso-moro@kerobbi

[8]ページ先頭

©2009-2025 Movatter.jp