mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(Linear Node): Fix issue with single item not being returned (#5193)
This commit is contained in:
parent
454375077f
commit
e810966a3b
|
@ -1,4 +1,4 @@
|
||||||
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow';
|
||||||
|
|
||||||
export class LinearApi implements ICredentialType {
|
export class LinearApi implements ICredentialType {
|
||||||
name = 'linearApi';
|
name = 'linearApi';
|
||||||
|
@ -16,4 +16,13 @@ export class LinearApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
Authorization: '={{$credentials.apiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,14 +22,11 @@ export async function linearApiRequest(
|
||||||
body: any = {},
|
body: any = {},
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = await this.getCredentials('linearApi');
|
|
||||||
|
|
||||||
const endpoint = 'https://api.linear.app/graphql';
|
const endpoint = 'https://api.linear.app/graphql';
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Authorization: credentials.apiKey,
|
|
||||||
},
|
},
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body,
|
body,
|
||||||
|
@ -38,7 +35,7 @@ export async function linearApiRequest(
|
||||||
};
|
};
|
||||||
options = Object.assign({}, options, option);
|
options = Object.assign({}, options, option);
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request(options);
|
return await this.helpers.requestWithAuthentication.call(this, 'linearApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ export class Linear implements INodeType {
|
||||||
};
|
};
|
||||||
|
|
||||||
responseData = await linearApiRequest.call(this, body);
|
responseData = await linearApiRequest.call(this, body);
|
||||||
responseData = responseData.data?.issues?.nodes[0];
|
responseData = responseData.data.issue;
|
||||||
}
|
}
|
||||||
if (operation === 'getAll') {
|
if (operation === 'getAll') {
|
||||||
const returnAll = this.getNodeParameter('returnAll', i);
|
const returnAll = this.getNodeParameter('returnAll', i);
|
||||||
|
|
|
@ -93,17 +93,14 @@ export const query = {
|
||||||
}`;
|
}`;
|
||||||
},
|
},
|
||||||
getIssue() {
|
getIssue() {
|
||||||
return `query Issue ($issueId: ID){
|
return `query Issue($issueId: String!) {
|
||||||
issues(filter: {
|
issue(id: $issueId) {
|
||||||
id: { eq: $issueId }
|
|
||||||
}) {
|
|
||||||
nodes {
|
|
||||||
id,
|
id,
|
||||||
title,
|
title,
|
||||||
priority
|
priority,
|
||||||
archivedAt
|
archivedAt,
|
||||||
assignee {
|
assignee {
|
||||||
id
|
id,
|
||||||
displayName
|
displayName
|
||||||
}
|
}
|
||||||
state {
|
state {
|
||||||
|
@ -122,7 +119,6 @@ export const query = {
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}`;
|
}`;
|
||||||
},
|
},
|
||||||
getIssues() {
|
getIssues() {
|
||||||
|
|
Loading…
Reference in a new issue