Skip to content

Tommy/expand-list-discussions-tool #690

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

tommaso-moro
Copy link
Contributor

Addresses #670

Overview
This PR adds

  • The updatedAt and author.login (i.e. username) fields to the discussions payload in the list_discussions tool
  • The ability to order discussions by field (updated_at and created_at) and direction (ascending order, descending order)

Refactoring
The PR includes refactoring of the list_discussions tool to handle optional parameters in our graphql queries. This was needed because the githubv4 library requires GraphQL queries to be defined using Go struct tags that must be known at compile time, so we could not dynamically construct query strings at runtime based on user input.

The changes made include

  • Introduced reusable DiscussionFragment struct to avoid field duplication
  • Created discussionQueries struct with 4 pre-defined query variants:
    • BasicNoOrder: No optional parameters (uses GitHub API's defaults)
    • BasicWithOrder: Only ordering parameters
    • WithCategoryNoOrder: Only category filtering
    • WithCategoryAndOrder: Both category and ordering
  • Implemented all-or-nothing validation for ordering (both orderBy and direction must be provided together)
  • Added runtime query selection logic to choose the appropriate variant based on user input

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.

1 participant