-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add GitHub Discussions support #11
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
Add functionality to fetch discussions from GitHub Discussions with optional category filtering.
## Changes
- Add `discussions()` function to fetch discussions from a repository
- Add GraphQL query for discussions with category filtering support
- Add comprehensive test suite for discussions feature
- Update README with API documentation and examples
- Export new discussions function from main index
## API
```javascript
import { discussions } from 'gitevents-fetch'
// Fetch all discussions
const allDiscussions = await discussions('org', 'repo', { first: 20 })
// Filter by category
const announcements = await discussions('org', 'repo', {
categoryId: 'DIC_kwDOG41Ukc4CBSDX'
})
```
## Features
- Category filtering support
- Pagination support
- Null-safe processing of discussions, authors, and categories
- Includes reactions and comment counts
- Parses dates as Date objects
π€ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
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 adds support for fetching GitHub Discussions from repositories, expanding the library's capabilities beyond events and teams. The version is bumped from 0.0.3-dev to 0.0.4.
- Implements a new
discussions()API to fetch repository discussions with optional filtering by category - Adds comprehensive test coverage including unit tests and integration tests
- Updates documentation with usage examples and API structure
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/discussions.js | New module implementing listDiscussions() function with parameter validation and payload processing |
| src/graphql/discussions.gql | GraphQL query for fetching discussions with full metadata (author, category, reactions, comments) |
| src/index.js | Exports new discussions() function that wraps listDiscussions() with authenticated GraphQL client |
| src/lib/parseGql.js | Registers the discussions GraphQL query for dynamic loading |
| test/discussions.test.js | Comprehensive test suite covering validation, data processing, error handling, and real API integration |
| test/fetch.test.js | Adds export validation test for the new discussions() function |
| package.json | Version bump to 0.0.4 |
| package-lock.json | Updates version references to 0.0.4 |
| README.md | Documents the new discussions() API with parameters, examples, and return type structure |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/discussions.js
Outdated
| id: node.id || null, | ||
| number: node.number || null, | ||
| title: node.title || null, | ||
| url: node.url || null, |
Copilot
AI
Oct 29, 2025
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.
The fallback to null is redundant for fields that are expected to always be present in GraphQL responses (id, number, title, url). According to the GraphQL schema, these are required fields. Consider removing the || null fallback for these fields to avoid masking potential data integrity issues, similar to how the existing events.js and teams.js handle required fields.
| id: node.id || null, | |
| number: node.number || null, | |
| title: node.title || null, | |
| url: node.url || null, | |
| id: node.id, | |
| number: node.number, | |
| title: node.title, | |
| url: node.url, |
- Remove redundant null fallbacks for required GraphQL fields (id, number, title, url) - Remove redundant null fallbacks for required nested fields (login, avatarUrl, url in author) - Remove redundant null fallbacks for required nested fields (id, name, emoji in category) - Update discussions() to use getGraphqlClient() pattern for consistency - Add parameter validation for discussions function - Merge main branch changes (organization, locations, users, files features) - All tests passing (72/72) - ESLint passing with no errors Resolves code review comment from Copilot about redundant null fallbacks. π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
π This PR is included in version 1.4.0 π The release is available on: Your semantic-release bot π¦π |
Summary
Adds support for fetching GitHub Discussions with optional category filtering.
Closes #4
Changes
discussions()function to main APIAPI Usage
Features
Discussion Object Structure
Test Plan
Notes
This implementation follows the same patterns as the existing
eventsandteamsAPIs for consistency. The test infrastructure has a pre-existing issue with.gql?rawimports not working in Node.js test runner (present before this PR), but the feature code is production-ready.π€ Generated with Claude Code