Add options to sideload owner and vendors
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -16,6 +16,35 @@ export const description: INodeProperties[] = [
|
||||
description: 'The ID of the asset',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['asset'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Include Owner',
|
||||
name: 'includeOwner',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to include owner details in the response',
|
||||
},
|
||||
{
|
||||
displayName: 'Include Vendors',
|
||||
name: 'includeVendors',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to include vendors in the response',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(
|
||||
@@ -23,6 +52,29 @@ export async function execute(
|
||||
itemIndex: number,
|
||||
): Promise<INodeExecutionData> {
|
||||
const assetId = this.getNodeParameter('assetId', itemIndex) as string;
|
||||
const options = this.getNodeParameter('options', itemIndex, {}) as {
|
||||
includeOwner?: boolean;
|
||||
includeVendors?: boolean;
|
||||
};
|
||||
|
||||
const ownerFragment = options.includeOwner
|
||||
? `owner {
|
||||
id
|
||||
fullName
|
||||
primaryEmailAddress
|
||||
}`
|
||||
: '';
|
||||
|
||||
const vendorsFragment = options.includeVendors
|
||||
? `vendors(first: 100) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}`
|
||||
: '';
|
||||
|
||||
const query = `
|
||||
query GetAsset($assetId: ID!) {
|
||||
@@ -33,6 +85,8 @@ export async function execute(
|
||||
amount
|
||||
assetType
|
||||
dataTypesStored
|
||||
${ownerFragment}
|
||||
${vendorsFragment}
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
@@ -51,4 +105,3 @@ export async function execute(
|
||||
pairedItem: { item: itemIndex },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user