mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
Feature/paired item support (#3869)
* Add paired item helper and implement it in some nodes
This commit is contained in:
@@ -324,6 +324,7 @@ export class GraphQL implements INodeType {
|
||||
let requestOptions: OptionsWithUri & RequestPromiseOptions;
|
||||
|
||||
const returnItems: INodeExecutionData[] = [];
|
||||
const responseData: IDataObject | IDataObject[] = [];
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
try {
|
||||
const requestMethod = this.getNodeParameter('requestMethod', itemIndex, 'POST') as string;
|
||||
@@ -334,7 +335,6 @@ export class GraphQL implements INodeType {
|
||||
'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(
|
||||
@@ -433,8 +433,7 @@ export class GraphQL implements INodeType {
|
||||
}
|
||||
if (responseFormat === 'string') {
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string;
|
||||
|
||||
returnItems.push({
|
||||
responseData.push({
|
||||
json: {
|
||||
[dataPropertyName]: response,
|
||||
},
|
||||
@@ -458,12 +457,23 @@ export class GraphQL implements INodeType {
|
||||
'Unexpected error';
|
||||
throw new NodeApiError(this.getNode(), response.errors, { message });
|
||||
}
|
||||
|
||||
returnItems.push({ json: response });
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: itemIndex } },
|
||||
);
|
||||
returnItems.push(...executionData);
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnItems.push({ json: { error: (error as JsonObject).message } });
|
||||
const errorData = this.helpers.returnJsonArray({
|
||||
$error: error,
|
||||
json: this.getInputData(itemIndex),
|
||||
itemIndex,
|
||||
});
|
||||
const exectionErrorWithMetaData = this.helpers.constructExecutionMetaData(errorData, {
|
||||
itemData: { item: itemIndex },
|
||||
});
|
||||
returnItems.push(...exectionErrorWithMetaData);
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user