From 8ec53912e751a568d3f0006c367689a06045dc2e Mon Sep 17 00:00:00 2001 From: Beau Cameron Date: Wed, 7 Aug 2024 20:06:40 -0600 Subject: [PATCH] Adding Default Selects Making select match v2 and v3 versions of this call. adding retrieveProperties to allow selecting custom properties --- packages/graph/taxonomy/types.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/graph/taxonomy/types.ts b/packages/graph/taxonomy/types.ts index a9f58510b..db0c7fd1c 100644 --- a/packages/graph/taxonomy/types.ts +++ b/packages/graph/taxonomy/types.ts @@ -77,16 +77,14 @@ export class _TermSet extends _GraphInstance { * * @returns Array of children for this item */ - public async getAllChildrenAsTree(): Promise { + public async getAllChildrenAsTree(props?: {retrieveProperties?: boolean}): Promise { - const visitor = async (source: { children(): Promise }, parent: IOrderedTermInfo[]) => { - - const children = await source.children(); + const visitor = async (source: ITerm | ITermSet, parent: IOrderedTermInfo[]) => { + const children = await source.children.select(...selects)(); for (let i = 0; i < children.length; i++) { const child = children[i]; - const orderedTerm: Partial = { children: [], defaultLabel: child.labels.find(l => l.isDefault).name, @@ -99,9 +97,15 @@ export class _TermSet extends _GraphInstance { } }; + let selects = ["*"]; + if(props?.retrieveProperties){ + // graph does not let us wildcard + select properties + selects=["id", "labels", "createdDateTime", "lastModifiedDateTime", "labels", "descriptions", "properties"]; + } + const tree: IOrderedTermInfo[] = []; - await visitor(this, tree); + await visitor(this, tree); return tree; }