[metadata] fix soft delete for standard objects missing deletedAt fieldMetadata (#7017)

This https://github.com/twentyhq/twenty/pull/7006 introduced a
regression.

The goal was to set "isSoftDeletable" to all standard objects but it was
done at the wrong level, meaning it was setting the boolean correctly
but not creating the corresponding fieldMetadata.

I took the occasion to update the new graphql query runner to use that
boolean and automatically add a filter on soft delete in case it's true.

Also adding **IsQueryRunnerTwentyORMEnabled** by default in the seeds
This commit is contained in:
Weiko 2024-09-13 12:03:27 +02:00 committed by GitHub
parent e9f8e6e718
commit 7fd86a860c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 13 additions and 5 deletions

View File

@ -55,6 +55,11 @@ export const seedFeatureFlags = async (
workspaceId: workspaceId,
value: false,
},
{
key: FeatureFlagKey.IsQueryRunnerTwentyORMEnabled,
workspaceId: workspaceId,
value: true,
},
])
.execute();
};

View File

@ -74,7 +74,7 @@ export class GraphqlQueryFindManyResolverService {
);
const where = graphqlQueryParser.parseFilter(
args.filter ?? ({} as Filter),
true,
objectMetadataItem.isSoftDeletable ?? false,
);
const cursor = this.getCursor(args);

View File

@ -56,7 +56,10 @@ export class GraphqlQueryFindOneResolverService {
objectMetadataItem,
graphqlFields(info),
);
const where = graphqlQueryParser.parseFilter(args.filter ?? ({} as Filter));
const where = graphqlQueryParser.parseFilter(
args.filter ?? ({} as Filter),
objectMetadataItem.isSoftDeletable ?? false,
);
const objectRecord = await repository.findOne({ where, select, relations });

View File

@ -48,7 +48,7 @@ export function WorkspaceEntity(
isAuditLogged,
isSystem,
gate,
softDelete: options.softDelete,
softDelete: options.softDelete ?? true,
});
};
}

View File

@ -64,5 +64,5 @@ export interface WorkspaceEntityMetadataArgs {
/**
* Enable soft delete.
*/
readonly softDelete?: boolean;
readonly softDelete: boolean;
}

View File

@ -54,7 +54,7 @@ export class StandardObjectFactory {
isCustom: false,
isRemote: false,
isSystem: workspaceEntityMetadataArgs.isSystem ?? false,
isSoftDeletable: workspaceEntityMetadataArgs.softDelete ?? true,
isSoftDeletable: workspaceEntityMetadataArgs.softDelete,
};
}
}