From 5c537e094db2fc0fff2415096fe3aaa87fb97b9c Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Wed, 15 Feb 2023 21:53:13 +0200 Subject: [PATCH] fix(server): retrieve nested graph accounts --- packages/server/src/services/Accounts/GetAccounts.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/server/src/services/Accounts/GetAccounts.ts b/packages/server/src/services/Accounts/GetAccounts.ts index 3599ddc23..ec2d1453a 100644 --- a/packages/server/src/services/Accounts/GetAccounts.ts +++ b/packages/server/src/services/Accounts/GetAccounts.ts @@ -5,6 +5,7 @@ import TenancyService from '@/services/Tenancy/TenancyService'; import DynamicListingService from '@/services/DynamicListing/DynamicListService'; import { AccountTransformer } from './AccountTransform'; import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable'; +import { flatToNestedArray } from '@/utils'; @Service() export class GetAccounts { @@ -53,11 +54,17 @@ export class GetAccounts { builder.modify('inactiveMode', filter.inactiveMode); }); // Retrievs the formatted accounts collection. - const transformedAccounts = await this.transformer.transform( + const preTransformedAccounts = await this.transformer.transform( tenantId, accounts, new AccountTransformer() ); + // Transform accounts to nested array. + const transformedAccounts = flatToNestedArray(preTransformedAccounts, { + id: 'id', + parentId: 'parentAccountId', + }); + return { accounts: transformedAccounts, filterMeta: dynamicList.getResponseMeta(),