Skip to content

feat: support the related issues API - #181

Merged
katayama8000 merged 2 commits into
nulab:masterfrom
katayama8000:feat/related-issues
Jul 28, 2026
Merged

feat: support the related issues API#181
katayama8000 merged 2 commits into
nulab:masterfrom
katayama8000:feat/related-issues

Conversation

@katayama8000

@katayama8000 katayama8000 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds client support for the issue relation ("related issues") endpoints:

Method Endpoint
getRelatedIssues(issueIdOrKey) GET /api/v2/issues/:issueIdOrKey/relatedIssues
addRelatedIssue(issueIdOrKey, params) POST /api/v2/issues/:issueIdOrKey/relatedIssues
removeRelatedIssue(issueIdOrKey, relatedIssueId) DELETE /api/v2/issues/:issueIdOrKey/relatedIssues/:relatedIssueId

Types

  • Entity.Issue.RelatedIssue extends Entity.Issue.Issue — the responses are plain Issue objects with an extra type field carrying the relation type, so extending Issue mirrors the wire format exactly.
  • Types.IssueRelationType = "RELATES" — kept to what the API actually supports today. The server also defines a reserved relation type that is neither accepted nor returned yet; exposing it here would leak an unreleased feature into the client surface, so it is intentionally left out and can be added when it ships.
  • Option.Issue.AddRelatedIssueParams = { targetIssueId: number }.

Usage

const related = await backlog.getRelatedIssues("SAMPLE-1");
//    ^? Entity.Issue.RelatedIssue[]   e.g. [{ id: 2, issueKey: "SAMPLE-2", type: "RELATES", ... }]

await backlog.addRelatedIssue("SAMPLE-1", { targetIssueId: 2 });
await backlog.removeRelatedIssue("SAMPLE-1", 2);

Verification

Unit tests were added for all three methods (the POST test also asserts the form-encoded request body).

The methods were additionally exercised against a real Backlog space, which confirmed:

  • addRelatedIssue / removeRelatedIssue return the target issue plus type: "RELATES".
  • The relation is undirected — after adding it from the source issue, getRelatedIssues on the target issue returns the source issue.
  • Adding the same relation twice is idempotent (the list stays at one entry).
  • Removing a relation that does not exist rejects with Error.BacklogApiError (HTTP 404), so no special handling is needed on the client side.

npm run typecheck, npm test, npm run lint and npm run fmt:check all pass.

Notes

The JSDoc comments reference the endpoint paths rather than developer.nulab.com URLs, because the documentation pages for these endpoints are not published yet. They should be swapped for the canonical URLs once the docs go live.

🤖 Generated with Claude Code

katayama8000 and others added 2 commits July 28, 2026 16:04
Add client methods for the issue relation endpoints:

- GET    /api/v2/issues/:issueIdOrKey/relatedIssues
- POST   /api/v2/issues/:issueIdOrKey/relatedIssues
- DELETE /api/v2/issues/:issueIdOrKey/relatedIssues/:relatedIssueId

The responses are Issue objects with an extra `type` field holding the
relation type, so `Entity.Issue.RelatedIssue` extends `Entity.Issue.Issue`.
`Types.IssueRelationType` covers "RELATES" and the reserved "PRECEDES".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Keep the public type within the scope the API actually supports today.
The server also defines a reserved PRECEDES type, but it is never accepted
or returned yet, so exposing it here would leak an unreleased feature into
the client surface.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@katayama8000
katayama8000 requested review from mdkn and mmktomato July 28, 2026 07:13

@mdkn mdkn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM!!!

@katayama8000
katayama8000 merged commit 03383e8 into nulab:master Jul 28, 2026
3 checks passed
@katayama8000
katayama8000 deleted the feat/related-issues branch July 28, 2026 07:18
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