Skip to content

Add parentIssue support to GitHubClient.createIssue for sub-issue functionality#1882

Merged
pelikhan merged 6 commits intodevfrom
copilot/fix-025f35e5-f039-48c7-b1fb-5c718e55b7d8
Aug 19, 2025
Merged

Add parentIssue support to GitHubClient.createIssue for sub-issue functionality#1882
pelikhan merged 6 commits intodevfrom
copilot/fix-025f35e5-f039-48c7-b1fb-5c718e55b7d8

Conversation

Copy link

Copilot AI commented Aug 19, 2025

This PR implements support for creating GitHub sub-issues by adding an optional parentIssue parameter to the GitHubClient.createIssue() method. When provided, the created issue is automatically linked as a sub-issue to the specified parent issue.

Problem

The GitHub client's createIssue method did not support creating sub-issues (child issues linked to a parent issue), which is a common workflow pattern for breaking down large features or epics into smaller, manageable tasks.

Solution

Enhanced the createIssue method to accept a parentIssue option that:

  1. Creates the issue normally using GitHub's REST API
  2. Establishes parent-child relationship via GraphQL createTaskListItem mutation
  3. Handles errors gracefully - issue creation succeeds even if sub-issue linking fails

Usage

// Create a parent epic
const epic = await github.createIssue("Epic: User Authentication", "...");

// Create linked sub-issues
const subIssue = await github.createIssue("Sub-task: Login Form", "...", {
  parentIssue: epic.number,
  labels: ["frontend", "sub-task"]
});

Changes Made

  • Type Definition: Added parentIssue?: number | string to GitHubIssueCreateOptions
  • Implementation: Modified createIssue to extract parentIssue and call new addSubIssue method
  • GraphQL Integration: Added private addSubIssue method using GitHub's task list API
  • Documentation: Updated GitHub reference docs with examples and API summary
  • Testing: Added comprehensive tests covering both scenarios (with/without parentIssue)
  • Sample Script: Added github-sub-issues.genai.mts demonstrating practical usage

Implementation Details

The implementation is minimal and non-breaking:

  • Existing code continues to work unchanged
  • parentIssue is extracted before REST API call to avoid parameter conflicts
  • Uses proper GraphQL mutation with node IDs for reliable linking
  • Includes debug logging and error handling
  • Graceful degradation ensures main operation always succeeds

Sample Script

The included GenAIScript sample (samples/sample/genaisrc/github-sub-issues.genai.mts) demonstrates:

  • Creating a parent epic issue with proper labeling
  • Automatically generating multiple sub-issues for different project phases
  • Using the parentIssue parameter to establish relationships
  • Real-world project management workflow patterns
  • Error handling and user feedback

This provides developers with a complete example of how to leverage sub-issues for organizing complex projects and breaking down large features into manageable tasks.

Testing

  • ✅ New functionality tested with mocked GraphQL calls
  • ✅ Backward compatibility verified (existing usage unchanged)
  • ✅ Build passes without compilation errors
  • ✅ All existing tests continue to pass
  • ✅ Sample script demonstrates practical usage

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits August 19, 2025 12:42
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] githubclient createIssue should support a parentIssue optional argument (in options). The created issue should be added as subissue to the parentIssue if available. Add parentIssue support to GitHubClient.createIssue for sub-issue functionality Aug 19, 2025
Copilot AI requested a review from pelikhan August 19, 2025 12:47
Copy link
Member

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

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

@copilot add a GenAIScript sample script under samples/sample that uses this feature.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Author

Copilot AI commented Aug 19, 2025

@copilot add a GenAIScript sample script under samples/sample that uses this feature.

Added GenAIScript sample github-sub-issues.genai.mts in samples/sample/genaisrc/ that demonstrates the parentIssue feature. The script creates a parent epic and automatically generates linked sub-issues showing practical project management workflow. Commit: afaa73c

Copilot AI requested a review from pelikhan August 19, 2025 13:01
@pelikhan pelikhan marked this pull request as ready for review August 19, 2025 14:11
@pelikhan pelikhan merged commit 9c1b6b8 into dev Aug 19, 2025
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.

2 participants