mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -33,9 +33,7 @@ export class GraphQL implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'basicAuth',
|
||||
],
|
||||
authentication: ['basicAuth'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -44,9 +42,7 @@ export class GraphQL implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'digestAuth',
|
||||
],
|
||||
authentication: ['digestAuth'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -55,9 +51,7 @@ export class GraphQL implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'headerAuth',
|
||||
],
|
||||
authentication: ['headerAuth'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -66,9 +60,7 @@ export class GraphQL implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'queryAuth',
|
||||
],
|
||||
authentication: ['queryAuth'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -77,9 +69,7 @@ export class GraphQL implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'oAuth1',
|
||||
],
|
||||
authentication: ['oAuth1'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -88,9 +78,7 @@ export class GraphQL implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'oAuth2',
|
||||
],
|
||||
authentication: ['oAuth2'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -165,7 +153,8 @@ export class GraphQL implements INodeType {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-ignore-ssl-issues
|
||||
description: 'Whether to download the response even if SSL certificate validation is not possible',
|
||||
description:
|
||||
'Whether to download the response even if SSL certificate validation is not possible',
|
||||
},
|
||||
{
|
||||
displayName: 'Request Format',
|
||||
@@ -184,9 +173,7 @@ export class GraphQL implements INodeType {
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
requestMethod: [
|
||||
'POST',
|
||||
],
|
||||
requestMethod: ['POST'],
|
||||
},
|
||||
},
|
||||
default: 'graphql',
|
||||
@@ -208,12 +195,8 @@ export class GraphQL implements INodeType {
|
||||
description: 'Query variables',
|
||||
displayOptions: {
|
||||
show: {
|
||||
requestFormat: [
|
||||
'json',
|
||||
],
|
||||
requestMethod: [
|
||||
'POST',
|
||||
],
|
||||
requestFormat: ['json'],
|
||||
requestMethod: ['POST'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -225,12 +208,8 @@ export class GraphQL implements INodeType {
|
||||
description: 'Name of operation to execute',
|
||||
displayOptions: {
|
||||
show: {
|
||||
requestFormat: [
|
||||
'json',
|
||||
],
|
||||
requestMethod: [
|
||||
'POST',
|
||||
],
|
||||
requestFormat: ['json'],
|
||||
requestMethod: ['POST'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -259,9 +238,7 @@ export class GraphQL implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
responseFormat: [
|
||||
'string',
|
||||
],
|
||||
responseFormat: ['string'],
|
||||
},
|
||||
},
|
||||
description: 'Name of the property to which to write the response data',
|
||||
@@ -304,9 +281,7 @@ export class GraphQL implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
|
||||
const items = this.getInputData();
|
||||
let httpBasicAuth;
|
||||
let httpDigestAuth;
|
||||
@@ -317,36 +292,35 @@ export class GraphQL implements INodeType {
|
||||
|
||||
try {
|
||||
httpBasicAuth = await this.getCredentials('httpBasicAuth');
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
// Do nothing
|
||||
}
|
||||
try {
|
||||
httpDigestAuth = await this.getCredentials('httpDigestAuth');
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
// Do nothing
|
||||
}
|
||||
try {
|
||||
httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
// Do nothing
|
||||
}
|
||||
try {
|
||||
httpQueryAuth = await this.getCredentials('httpQueryAuth');
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
// Do nothing
|
||||
}
|
||||
try {
|
||||
oAuth1Api = await this.getCredentials('oAuth1Api');
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
// Do nothing
|
||||
}
|
||||
try {
|
||||
oAuth2Api = await this.getCredentials('oAuth2Api');
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
let requestOptions: OptionsWithUri & RequestPromiseOptions;
|
||||
|
||||
const returnItems: INodeExecutionData[] = [];
|
||||
@@ -354,15 +328,22 @@ export class GraphQL implements INodeType {
|
||||
try {
|
||||
const requestMethod = this.getNodeParameter('requestMethod', itemIndex, 'POST') as string;
|
||||
const endpoint = this.getNodeParameter('endpoint', itemIndex, '') as string;
|
||||
const requestFormat = this.getNodeParameter('requestFormat', itemIndex, 'graphql') as string;
|
||||
const requestFormat = this.getNodeParameter(
|
||||
'requestFormat',
|
||||
itemIndex,
|
||||
'graphql',
|
||||
) as string;
|
||||
const responseFormat = this.getNodeParameter('responseFormat', 0) as string;
|
||||
|
||||
const { parameter }: { parameter?: Array<{ name: string, value: string }> } = this
|
||||
.getNodeParameter('headerParametersUi', itemIndex, {}) as IDataObject;
|
||||
const headerParameters = (parameter || []).reduce((result, item) => ({
|
||||
...result,
|
||||
[item.name]: item.value,
|
||||
}), {});
|
||||
const { parameter }: { parameter?: Array<{ name: string; value: string }> } =
|
||||
this.getNodeParameter('headerParametersUi', itemIndex, {}) as IDataObject;
|
||||
const headerParameters = (parameter || []).reduce(
|
||||
(result, item) => ({
|
||||
...result,
|
||||
[item.name]: item.value,
|
||||
}),
|
||||
{},
|
||||
);
|
||||
|
||||
requestOptions = {
|
||||
headers: {
|
||||
@@ -372,7 +353,11 @@ export class GraphQL implements INodeType {
|
||||
method: requestMethod,
|
||||
uri: endpoint,
|
||||
simple: false,
|
||||
rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false) as boolean,
|
||||
rejectUnauthorized: !this.getNodeParameter(
|
||||
'allowUnauthorizedCerts',
|
||||
itemIndex,
|
||||
false,
|
||||
) as boolean,
|
||||
};
|
||||
|
||||
// Add credentials if any are set
|
||||
@@ -416,7 +401,14 @@ export class GraphQL implements INodeType {
|
||||
try {
|
||||
requestOptions.body.variables = JSON.parse(requestOptions.body.variables || '{}');
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), 'Using variables failed:\n' + requestOptions.body.variables + '\n\nWith error message:\n' + error, { itemIndex });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Using variables failed:\n' +
|
||||
requestOptions.body.variables +
|
||||
'\n\nWith error message:\n' +
|
||||
error,
|
||||
{ itemIndex },
|
||||
);
|
||||
}
|
||||
}
|
||||
if (requestOptions.body.operationName === '') {
|
||||
@@ -433,7 +425,9 @@ export class GraphQL implements INodeType {
|
||||
if (oAuth1Api !== undefined) {
|
||||
response = await this.helpers.requestOAuth1.call(this, 'oAuth1Api', requestOptions);
|
||||
} else if (oAuth2Api !== undefined) {
|
||||
response = await this.helpers.requestOAuth2.call(this, 'oAuth2Api', requestOptions, { tokenType: 'Bearer' });
|
||||
response = await this.helpers.requestOAuth2.call(this, 'oAuth2Api', requestOptions, {
|
||||
tokenType: 'Bearer',
|
||||
});
|
||||
} else {
|
||||
response = await this.helpers.request(requestOptions);
|
||||
}
|
||||
@@ -450,12 +444,18 @@ export class GraphQL implements INodeType {
|
||||
try {
|
||||
response = JSON.parse(response);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"', { itemIndex });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Response body is not valid JSON. Change "Response Format" to "String"',
|
||||
{ itemIndex },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (response.errors) {
|
||||
const message = response.errors?.map((error: IDataObject) => error.message).join(', ') || 'Unexpected error';
|
||||
const message =
|
||||
response.errors?.map((error: IDataObject) => error.message).join(', ') ||
|
||||
'Unexpected error';
|
||||
throw new NodeApiError(this.getNode(), response.errors, { message });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user