Skip to content

Commit 0cd7489

Browse files
committed
rebase
1 parent 0380223 commit 0cd7489

19 files changed

+64
-73
lines changed

packages/twenty-server/src/engine/api/common/common-query-runners/common-create-many-query-runner/common-create-many-query-runner.service.ts

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,56 @@ export class CommonCreateManyQueryRunnerService extends CommonBaseQueryRunnerSer
6767
selectedFieldsResult: args.selectedFieldsResult,
6868
});
6969

70-
if (!isDefined(args.selectedFieldsResult.relations)) {
71-
await this.processNestedRelationsHelper.processNestedRelations({
72-
objectMetadataMaps,
73-
parentObjectMetadataItem: objectMetadataItemWithFieldMaps,
74-
parentObjectRecords: upsertedRecords,
75-
//TODO : Refacto-common - Typing to fix when switching processNestedRelationsHelper to Common
76-
relations: args.selectedFieldsResult.relations as Record<
77-
string,
78-
FindOptionsRelations<ObjectLiteral>
79-
>,
80-
limit: QUERY_MAX_RECORDS,
81-
authContext,
82-
workspaceDataSource,
83-
rolePermissionConfig,
84-
selectedFields: args.selectedFieldsResult.select,
85-
});
86-
}
70+
await this.processNestedRelationsIfNeeded({
71+
args,
72+
records: upsertedRecords,
73+
objectMetadataItemWithFieldMaps,
74+
objectMetadataMaps,
75+
authContext,
76+
workspaceDataSource,
77+
rolePermissionConfig,
78+
});
8779

8880
return upsertedRecords;
8981
}
9082

83+
private async processNestedRelationsIfNeeded({
84+
args,
85+
records,
86+
objectMetadataItemWithFieldMaps,
87+
objectMetadataMaps,
88+
authContext,
89+
workspaceDataSource,
90+
rolePermissionConfig,
91+
}: {
92+
args: CommonExtendedInput<CreateManyQueryArgs>;
93+
records: ObjectRecord[];
94+
objectMetadataItemWithFieldMaps: ObjectMetadataItemWithFieldMaps;
95+
objectMetadataMaps: ObjectMetadataMaps;
96+
authContext: AuthContext;
97+
workspaceDataSource: WorkspaceDataSource;
98+
rolePermissionConfig?: RolePermissionConfig;
99+
}): Promise<void> {
100+
if (!args.selectedFieldsResult.relations) {
101+
return;
102+
}
103+
104+
await this.processNestedRelationsHelper.processNestedRelations({
105+
objectMetadataMaps,
106+
parentObjectMetadataItem: objectMetadataItemWithFieldMaps,
107+
parentObjectRecords: records,
108+
relations: args.selectedFieldsResult.relations as Record<
109+
string,
110+
FindOptionsRelations<ObjectLiteral>
111+
>,
112+
limit: QUERY_MAX_RECORDS,
113+
authContext,
114+
workspaceDataSource,
115+
rolePermissionConfig,
116+
selectedFields: args.selectedFieldsResult.select,
117+
});
118+
}
119+
91120
async computeArgs(
92121
args: CommonInput<CreateManyQueryArgs>,
93122
queryRunnerContext: CommonBaseQueryRunnerContext,
@@ -355,44 +384,6 @@ export class CommonCreateManyQueryRunnerService extends CommonBaseQueryRunnerSer
355384
return upsertedRecords as ObjectRecord[];
356385
}
357386

358-
private async processNestedRelationsIfNeeded({
359-
records,
360-
objectMetadataItemWithFieldMaps,
361-
objectMetadataMaps,
362-
rolePermissionConfig,
363-
authContext,
364-
workspaceDataSource,
365-
selectedFieldsResult,
366-
}: {
367-
records: ObjectRecord[];
368-
objectMetadataItemWithFieldMaps: ObjectMetadataItemWithFieldMaps;
369-
objectMetadataMaps: ObjectMetadataMaps;
370-
authContext: AuthContext;
371-
workspaceDataSource: WorkspaceDataSource;
372-
rolePermissionConfig?: RolePermissionConfig;
373-
selectedFieldsResult: CommonSelectedFieldsResult;
374-
}): Promise<void> {
375-
if (!selectedFieldsResult.relations) {
376-
return;
377-
}
378-
379-
await this.processNestedRelationsHelper.processNestedRelations({
380-
objectMetadataMaps,
381-
parentObjectMetadataItem: objectMetadataItemWithFieldMaps,
382-
parentObjectRecords: records,
383-
//TODO : Refacto-common - Typing to fix when switching processNestedRelationsHelper to Common
384-
relations: selectedFieldsResult.relations as Record<
385-
string,
386-
FindOptionsRelations<ObjectLiteral>
387-
>,
388-
limit: QUERY_MAX_RECORDS,
389-
authContext,
390-
workspaceDataSource,
391-
rolePermissionConfig,
392-
selectedFields: selectedFieldsResult.select,
393-
});
394-
}
395-
396387
private getRecordWithoutCreatedBy(
397388
record: PartialObjectRecordWithId,
398389
objectMetadataItemWithFieldMaps: ObjectMetadataItemWithFieldMaps,

packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/create-many-resolver.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class CreateManyResolverFactory
5252
const records = await this.commonCreateManyQueryRunnerService.execute(
5353
{ ...args, selectedFields },
5454
internalContext,
55-
CommonQueryNames.createMany,
55+
CommonQueryNames.CREATE_MANY,
5656
);
5757

5858
const typeORMObjectRecordsParser =

packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/create-one-resolver.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class CreateOneResolverFactory
4949
const record = await this.commonCreateOneQueryRunnerService.execute(
5050
{ ...args, selectedFields },
5151
internalContext,
52-
CommonQueryNames.createOne,
52+
CommonQueryNames.CREATE_ONE,
5353
);
5454

5555
const typeORMObjectRecordsParser =

packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/delete-many-resolver.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class DeleteManyResolverFactory
5252
const records = await this.commonDeleteManyQueryRunnerService.execute(
5353
{ ...args, selectedFields },
5454
internalContext,
55-
CommonQueryNames.deleteMany,
55+
CommonQueryNames.DELETE_MANY,
5656
);
5757

5858
const typeORMObjectRecordsParser =

packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/delete-one-resolver.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class DeleteOneResolverFactory
5151
const record = await this.commonDeleteOneQueryRunnerService.execute(
5252
{ ...args, selectedFields },
5353
internalContext,
54-
CommonQueryNames.deleteOne,
54+
CommonQueryNames.DELETE_ONE,
5555
);
5656

5757
const typeORMObjectRecordsParser =

packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/destroy-many-resolver.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class DestroyManyResolverFactory
5353
await this.commonDestroyManyQueryRunnerService.execute(
5454
{ ...args, selectedFields },
5555
internalContext,
56-
CommonQueryNames.destroyMany,
56+
CommonQueryNames.DESTROY_MANY,
5757
);
5858

5959
const typeORMObjectRecordsParser =

packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/destroy-one-resolver.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class DestroyOneResolverFactory
5151
const record = await this.commonDestroyOneQueryRunnerService.execute(
5252
{ ...args, selectedFields },
5353
internalContext,
54-
CommonQueryNames.destroyOne,
54+
CommonQueryNames.DESTROY_ONE,
5555
);
5656

5757
const typeORMObjectRecordsParser =

packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/find-many-resolver.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class FindManyResolverFactory
5555
} = await this.commonFindManyQueryRunnerService.execute(
5656
{ ...args, selectedFields },
5757
internalContext,
58-
CommonQueryNames.findMany,
58+
CommonQueryNames.FIND_MANY,
5959
);
6060

6161
const typeORMObjectRecordsParser =

packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/find-one-resolver.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class FindOneResolverFactory
4848
const record = await this.commonFindOneQueryRunnerService.execute(
4949
{ ...args, selectedFields },
5050
internalContext,
51-
CommonQueryNames.findOne,
51+
CommonQueryNames.FIND_ONE,
5252
);
5353

5454
const typeORMObjectRecordsParser =

packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/group-by-resolver.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class GroupByResolverFactory
4848
return await this.commonGroupByQueryRunnerService.execute(
4949
{ ...args, selectedFields },
5050
internalContext,
51-
CommonQueryNames.groupBy,
51+
CommonQueryNames.GROUP_BY,
5252
);
5353
} catch (error) {
5454
return workspaceQueryRunnerGraphqlApiExceptionHandler(error);

0 commit comments

Comments
 (0)