Build a Graphql query statement for the provided queries.
(queries: NonNullable<CaretakerConfig['githubQueries']>)
| 80 | |
| 81 | /** Build a Graphql query statement for the provided queries. */ |
| 82 | private buildGraphqlQuery(queries: NonNullable<CaretakerConfig['githubQueries']>) { |
| 83 | /** The query object for graphql. */ |
| 84 | const graphqlQuery: GithubQueryResult = {}; |
| 85 | const {owner, name: repo} = this.git.remoteConfig; |
| 86 | /** The Github search filter for the configured repository. */ |
| 87 | const repoFilter = `repo:${owner}/${repo}`; |
| 88 | |
| 89 | queries.forEach(({name, query}) => { |
| 90 | /** The name of the query, with spaces removed to match Graphql requirements. */ |
| 91 | const queryKey = alias(name.replace(/ /g, ''), 'search'); |
| 92 | graphqlQuery[queryKey] = params( |
| 93 | { |
| 94 | type: 'ISSUE', |
| 95 | first: MAX_RETURNED_ISSUES, |
| 96 | query: `"${repoFilter} ${query.replace(/\"/g, '\\"')}"`, |
| 97 | }, |
| 98 | {...GithubQueryResultFragment}, |
| 99 | ); |
| 100 | }); |
| 101 | |
| 102 | return graphqlQuery; |
| 103 | } |
| 104 | |
| 105 | override async printToTerminal() { |
| 106 | const queryResults = await this.data; |