Skip to content
Back to skills

Github Graphql Api

ASecurity

GitHub REST APIのSub-issue関連バグを回避するためのGraphQL API共通処理(Sub-issue登録、エラーハンドリング)を提供

  • 666 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 8, 2026
developmentpythonbashnodegitapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill github-graphql-api-takemo101-compose-workflow-2 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Github Graphql Api?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Github Graphql Api
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-github-graphql-api/badge)](https://www.skillsdirectory.com/skills/majiayu000-github-graphql-api)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: github-graphql-api
description: GitHub REST APIのSub-issue関連バグを回避するためのGraphQL API共通処理(Sub-issue登録、エラーハンドリング)を提供
---

# GitHub GraphQL API共通処理

> **参照元**: decompose-issue.md, detailed-design-workflow.md から分離された共通GraphQL API処理

---

## 概要

GitHub REST APIにはSub-issue関連のバグがあるため、GraphQL APIを使用する。

**Reference**: https://github.com/cli/cli/issues/10378

---

## Sub-issue登録

親IssueにSub-issueを紐付けるGraphQL API処理。

### 処理フロー

```python
def add_sub_issue(parent_issue_id: int, child_issue_id: int) -> bool:
    """
    親IssueにSub-issueを登録する
    
    Args:
        parent_issue_id: 親Issue番号
        child_issue_id: 子Issue番号(Sub-issue)
    
    Returns:
        成功時True、失敗時False(致命的エラーとしない)
    """
    try:
        # 1. GraphQL Node IDを取得
        parent_node_id = bash(
            f"gh issue view {parent_issue_id} --json id --jq '.id'"
        ).stdout.strip()
        
        child_node_id = bash(
            f"gh issue view {child_issue_id} --json id --jq '.id'"
        ).stdout.strip()
        
        if not parent_node_id or not child_node_id:
            return False
        
        # 2. GraphQL APIでSub-issue関係を追加
        result = bash(f'''
            gh api graphql \
              -H "GraphQL-Features: sub_issues" \
              -f 'query=mutation {{
                addSubIssue(input: {{
                  issueId: "{parent_node_id}",
                  subIssueId: "{child_node_id}"
                }}) {{
                  issue {{ number }}
                  subIssue {{ number }}
                }}
              }}'
        ''')
        
        return result.exit_code == 0
        
    except Exception:
        return False  # Sub-issue登録失敗は致命的エラーとしない
```

### シェルコマンド版

```bash
# 1. Node ID取得
PARENT_NODE_ID=$(gh issue view $PARENT_ISSUE_ID --json id --jq '.id')
CHILD_NODE_ID=$(gh issue view $CHILD_ISSUE_ID --json id --jq '.id')

# 2. Sub-issue登録
gh api graphql \
  -H "GraphQL-Features: sub_issues" \
  -f "query=mutation {
    addSubIssue(input: {
      issueId: \"$PARENT_NODE_ID\",
      subIssueId: \"$CHILD_NODE_ID\"
    }) {
      issue { number }
      subIssue { number }
    }
  }" || true  # エラーでも続行
```

---

## エラーハンドリング

| エラー | 対応 |
|--------|------|
| Node ID取得失敗 | 処理をスキップ(警告ログ出力) |
| GraphQL API失敗 | 処理をスキップ(致命的エラーとしない) |
| ネットワークエラー | リトライ1回後スキップ |

**重要**: Sub-issue登録の失敗はワークフロー全体を停止させない。Issue自体は作成済みなので、手動でSub-issue関係を設定可能。

---

## 使用箇所

| ワークフロー | 用途 |
|-------------|------|
| `/decompose-issue` | 分割したSubtaskを親Issueに紐付け |
| `/detailed-design-workflow` | 作成したIssueをEpicに紐付け |

---

## CLIスクリプト

**自動化スクリプトが利用可能です:**

```bash
bash .opencode/skill/github-graphql-api/scripts/add-sub-issue.sh <parent-issue> <child-issue>
```

| 引数 | 説明 |
|------|------|
| `parent-issue` | 親Issue番号 |
| `child-issue` | Sub-issueとして追加するIssue番号 |

**使用例:**
```bash
bash .opencode/skill/github-graphql-api/scripts/add-sub-issue.sh 10 42
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.