Add connect API to n8n execute
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -1,7 +1,32 @@
|
|||||||
import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
||||||
import { proboApiRequest } from '../../GenericFunctions';
|
import { proboApiRequest, proboConnectApiRequest } from '../../GenericFunctions';
|
||||||
|
|
||||||
export const description: INodeProperties[] = [
|
export const description: INodeProperties[] = [
|
||||||
|
{
|
||||||
|
displayName: 'API',
|
||||||
|
name: 'api',
|
||||||
|
type: 'options',
|
||||||
|
noDataExpression: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: ['execute'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Console API',
|
||||||
|
value: 'console',
|
||||||
|
description: 'Call the Console GraphQL API (/api/console/v1/graphql)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Connect API',
|
||||||
|
value: 'connect',
|
||||||
|
description: 'Call the Connect GraphQL API (/api/connect/v1/graphql)',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'console',
|
||||||
|
description: 'Which Probo API to call',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Query',
|
displayName: 'Query',
|
||||||
name: 'query',
|
name: 'query',
|
||||||
@@ -36,6 +61,7 @@ export async function execute(
|
|||||||
this: IExecuteFunctions,
|
this: IExecuteFunctions,
|
||||||
itemIndex: number,
|
itemIndex: number,
|
||||||
): Promise<INodeExecutionData> {
|
): Promise<INodeExecutionData> {
|
||||||
|
const api = this.getNodeParameter('api', itemIndex, 'console') as string;
|
||||||
const query = this.getNodeParameter('query', itemIndex) as string;
|
const query = this.getNodeParameter('query', itemIndex) as string;
|
||||||
const variablesParam = this.getNodeParameter('variables', itemIndex) as string;
|
const variablesParam = this.getNodeParameter('variables', itemIndex) as string;
|
||||||
|
|
||||||
@@ -63,7 +89,8 @@ export async function execute(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const responseData = await proboApiRequest.call(this, query, variables);
|
const requestFn = api === 'connect' ? proboConnectApiRequest : proboApiRequest;
|
||||||
|
const responseData = await requestFn.call(this, query, variables);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
json: responseData,
|
json: responseData,
|
||||||
|
|||||||
Reference in New Issue
Block a user