File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { z } from "zod"
22
33import { postToLinear } from "../post-to-linear"
4- import { type LinearIssue , linearIssueFragment , linearIssueSchema } from "./schema"
4+ import { linearIssueFragment , linearIssueSchema } from "./schema"
55
66const query = `query SearchIssues($searchQuery: String!) {
7- issues(filter: { title: { startsWithIgnoreCase: $searchQuery } } ) {
7+ searchIssues(term: $searchQuery) {
88 nodes {
99 ${ linearIssueFragment }
1010 }
1111 }
1212}`
1313
14- export default async function searchIssues ( searchQuery : string ) : Promise < LinearIssue [ ] > {
14+ export default async function searchIssues (
15+ searchQuery : string
16+ ) : Promise < { id : string ; title : string ; identifier : string } [ ] > {
1517 const result = await postToLinear ( { query, variables : { searchQuery} } )
1618
17- if ( result . data . issues . nodes . length === 0 ) {
19+ if ( result . data . searchIssues . nodes . length === 0 ) {
1820 return [ ]
1921 }
2022
21- return z . array ( linearIssueSchema ) . parse ( result . data . issues . nodes )
23+ return z . array ( linearIssueSchema ) . parse ( result . data . searchIssues . nodes )
2224}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import {postToLinear} from "../post-to-linear"
44import { type LinearProject , linearProjectFragment , linearProjectSchema } from "./schema"
55
66const query = `query SearchProjects($searchQuery: String!) {
7- projects(filter: { name: { startsWithIgnoreCase: $searchQuery } } ) {
7+ searchProjects(term: $searchQuery) {
88 nodes {
99 ${ linearProjectFragment }
1010 }
@@ -14,9 +14,9 @@ const query = `query SearchProjects($searchQuery: String!) {
1414export default async function searchProjects ( searchQuery : string ) : Promise < LinearProject [ ] > {
1515 const result = await postToLinear ( { query, variables : { searchQuery} } )
1616
17- if ( result . data . projects . nodes . length === 0 ) {
17+ if ( result . data . searchProjects . nodes . length === 0 ) {
1818 return [ ]
1919 }
2020
21- return z . array ( linearProjectSchema ) . parse ( result . data . projects . nodes )
21+ return z . array ( linearProjectSchema ) . parse ( result . data . searchProjects . nodes )
2222}
You can’t perform that action at this time.
0 commit comments