diff --git a/packages/nodes-base/credentials/LinearApi.credentials.ts b/packages/nodes-base/credentials/LinearApi.credentials.ts index 3b96080274..203e67543b 100644 --- a/packages/nodes-base/credentials/LinearApi.credentials.ts +++ b/packages/nodes-base/credentials/LinearApi.credentials.ts @@ -1,4 +1,4 @@ -import { ICredentialType, INodeProperties } from 'n8n-workflow'; +import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow'; export class LinearApi implements ICredentialType { name = 'linearApi'; @@ -16,4 +16,13 @@ export class LinearApi implements ICredentialType { default: '', }, ]; + + authenticate: IAuthenticateGeneric = { + type: 'generic', + properties: { + headers: { + Authorization: '={{$credentials.apiKey}}', + }, + }, + }; } diff --git a/packages/nodes-base/nodes/Linear/GenericFunctions.ts b/packages/nodes-base/nodes/Linear/GenericFunctions.ts index 30e7428f40..fef5450a04 100644 --- a/packages/nodes-base/nodes/Linear/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Linear/GenericFunctions.ts @@ -22,14 +22,11 @@ export async function linearApiRequest( body: any = {}, option: IDataObject = {}, ): Promise { - const credentials = await this.getCredentials('linearApi'); - const endpoint = 'https://api.linear.app/graphql'; let options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', - Authorization: credentials.apiKey, }, method: 'POST', body, @@ -38,7 +35,7 @@ export async function linearApiRequest( }; options = Object.assign({}, options, option); try { - return await this.helpers.request(options); + return await this.helpers.requestWithAuthentication.call(this, 'linearApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } diff --git a/packages/nodes-base/nodes/Linear/Linear.node.ts b/packages/nodes-base/nodes/Linear/Linear.node.ts index be81032de4..2b66c34aa2 100644 --- a/packages/nodes-base/nodes/Linear/Linear.node.ts +++ b/packages/nodes-base/nodes/Linear/Linear.node.ts @@ -202,7 +202,7 @@ export class Linear implements INodeType { }; responseData = await linearApiRequest.call(this, body); - responseData = responseData.data?.issues?.nodes[0]; + responseData = responseData.data.issue; } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); diff --git a/packages/nodes-base/nodes/Linear/Queries.ts b/packages/nodes-base/nodes/Linear/Queries.ts index 993deed39e..861b404d3f 100644 --- a/packages/nodes-base/nodes/Linear/Queries.ts +++ b/packages/nodes-base/nodes/Linear/Queries.ts @@ -93,34 +93,30 @@ export const query = { }`; }, getIssue() { - return `query Issue ($issueId: ID){ - issues(filter: { - id: { eq: $issueId } - }) { - nodes { + return `query Issue($issueId: String!) { + issue(id: $issueId) { + id, + title, + priority, + archivedAt, + assignee { id, - title, - priority - archivedAt - assignee { - id - displayName - } - state { - id - name - } - createdAt - creator { - id - displayName - } - description - dueDate - cycle { - id - name - } + displayName + } + state { + id + name + } + createdAt + creator { + id + displayName + } + description + dueDate + cycle { + id + name } } }`; @@ -129,7 +125,7 @@ export const query = { return `query Issue ($first: Int){ issues (first: $first){ nodes { - id, + id, title, priority archivedAt