Skip to content

Commit 2711def

Browse files
authored
Merge pull request #31 from OasAIStudio/linear-compat-fix
Fix Linear candidate query compatibility
2 parents 76eee2b + bb53e6e commit 2711def

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

src/tracker/linear-client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export class LinearTrackerClient implements IssueTracker {
8383
projectSlug: this.requireProjectSlug(),
8484
activeStates: this.activeStates,
8585
first: this.pageSize,
86+
relationFirst: this.pageSize,
8687
});
8788
}
8889

@@ -95,6 +96,7 @@ export class LinearTrackerClient implements IssueTracker {
9596
projectSlug: this.requireProjectSlug(),
9697
stateNames,
9798
first: this.pageSize,
99+
relationFirst: this.pageSize,
98100
});
99101
}
100102

src/tracker/linear-normalize.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ interface LinearIssueNode {
2525
}> | null;
2626
inverseRelations?: LinearConnection<{
2727
type?: unknown;
28+
issue?: {
29+
id?: unknown;
30+
identifier?: unknown;
31+
state?: {
32+
name?: unknown;
33+
} | null;
34+
} | null;
2835
sourceIssue?: {
2936
id?: unknown;
3037
identifier?: unknown;
@@ -145,7 +152,7 @@ function normalizeBlockedBy(
145152
return [];
146153
}
147154

148-
return [normalizeBlocker(relation.sourceIssue)];
155+
return [normalizeBlocker(relation.issue ?? relation.sourceIssue)];
149156
});
150157
}
151158

src/tracker/linear-queries.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const ISSUE_FIELDS = `
66
priority
77
branchName
88
url
9+
assignee {
10+
id
11+
}
912
createdAt
1013
updatedAt
1114
state {
@@ -16,10 +19,10 @@ const ISSUE_FIELDS = `
1619
name
1720
}
1821
}
19-
inverseRelations {
22+
inverseRelations(first: $relationFirst) {
2023
nodes {
2124
type
22-
sourceIssue {
25+
issue {
2326
id
2427
identifier
2528
state {
@@ -35,6 +38,7 @@ export const LINEAR_CANDIDATE_ISSUES_QUERY = `
3538
$projectSlug: String!
3639
$activeStates: [String!]!
3740
$first: Int!
41+
$relationFirst: Int!
3842
$after: String
3943
) {
4044
issues(
@@ -62,6 +66,7 @@ export const LINEAR_ISSUES_BY_STATES_QUERY = `
6266
$projectSlug: String!
6367
$stateNames: [String!]!
6468
$first: Int!
69+
$relationFirst: Int!
6570
$after: String
6671
) {
6772
issues(

tests/tracker/linear-client.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ describe("LinearTrackerClient", () => {
7373
projectSlug: "ENG",
7474
activeStates: ["Todo", "In Progress"],
7575
first: 50,
76+
relationFirst: 50,
7677
after: null,
7778
});
7879

@@ -81,6 +82,7 @@ describe("LinearTrackerClient", () => {
8182
projectSlug: "ENG",
8283
activeStates: ["Todo", "In Progress"],
8384
first: 50,
85+
relationFirst: 50,
8486
after: "cursor-1",
8587
});
8688
});
@@ -288,6 +290,7 @@ function issueNode(input: {
288290
priority: 2,
289291
branchName: null,
290292
url: null,
293+
assignee: null,
291294
createdAt: input.createdAt,
292295
updatedAt: input.createdAt,
293296
state: {

tests/tracker/linear-normalize.test.ts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("linear-normalize", () => {
2929
nodes: [
3030
{
3131
type: "blocks",
32-
sourceIssue: {
32+
issue: {
3333
id: "issue-0",
3434
identifier: "ENG-100",
3535
state: {
@@ -39,7 +39,7 @@ describe("linear-normalize", () => {
3939
},
4040
{
4141
type: "relatesTo",
42-
sourceIssue: {
42+
issue: {
4343
id: "issue-x",
4444
identifier: "ENG-X",
4545
state: {
@@ -73,6 +73,39 @@ describe("linear-normalize", () => {
7373
});
7474
});
7575

76+
it("accepts legacy blocker payloads that still use sourceIssue", () => {
77+
const issue = normalizeLinearIssue({
78+
id: "issue-1",
79+
identifier: "ENG-123",
80+
title: "Implement adapter",
81+
state: {
82+
name: "Todo",
83+
},
84+
inverseRelations: {
85+
nodes: [
86+
{
87+
type: "blocks",
88+
sourceIssue: {
89+
id: "issue-0",
90+
identifier: "ENG-100",
91+
state: {
92+
name: "In Progress",
93+
},
94+
},
95+
},
96+
],
97+
},
98+
});
99+
100+
expect(issue.blockedBy).toEqual([
101+
{
102+
id: "issue-0",
103+
identifier: "ENG-100",
104+
state: "In Progress",
105+
},
106+
]);
107+
});
108+
76109
it("returns null for non-integer priority and invalid timestamps", () => {
77110
const issue = normalizeLinearIssue({
78111
id: "issue-1",

0 commit comments

Comments
 (0)