add WorkspaceDuplicateCriteria decorator + update duplicate resolver logic (#10128)

## Context

All objects have '...duplicates' resolver but only companies and people
have duplicate criteria (hard coded constant).
Gql schema and resolver should be created only if duplicate criteria
exist.

## Solution

- Add a new @WorkspaceDuplicateCriteria decorator at object level,
defining duplicate criteria for given object.
- Add a new duplicate criteria field in ObjectMetadata table
- Update schema and resolver building logic
- Update front requests for duplicate check (only for object with
criteria defined)



closes https://github.com/twentyhq/twenty/issues/9828
This commit is contained in:
Etienne
2025-02-12 17:32:59 +01:00
committed by GitHub
parent b66289c44c
commit 0609b31c64
29 changed files with 491 additions and 121 deletions

View File

@ -63,9 +63,18 @@ export class WorkspaceObjectComparator {
for (const difference of objectMetadataDifference) {
// We only handle CHANGE here as REMOVE and CREATE are handled earlier.
if (difference.type === 'CHANGE') {
// If the old value and the new value are both null, skip
// Database is storing null, and we can get undefined here
if (
difference.oldValue === null &&
(difference.value === null || difference.value === undefined)
) {
continue;
}
const property = difference.path[0];
objectPropertiesToUpdate[property] = difference.value;
objectPropertiesToUpdate[property] = standardObjectMetadata[property];
}
}