feat: refactor custom object (#1887)

* chore: drop old universal entity

* feat: wip refactor graphql generation custom object

* feat: refactor custom object resolvers

fix: tests

fix: import

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Jérémy M
2023-10-10 10:50:54 +02:00
committed by GitHub
parent 18c8f26f38
commit 017a0b1563
33 changed files with 588 additions and 770 deletions

View File

@ -0,0 +1,23 @@
import isEmpty from 'lodash.isempty';
export const convertFieldsToGraphQL = (
fields: any,
fieldAliases: Record<string, string>,
acc = '',
) => {
for (const [key, value] of Object.entries(fields)) {
if (value && !isEmpty(value)) {
acc += `${key} {\n`;
acc = convertFieldsToGraphQL(value, fieldAliases, acc);
acc += `}\n`;
} else {
if (fieldAliases[key]) {
acc += `${key}: ${fieldAliases[key]}\n`;
} else {
acc += `${key}\n`;
}
}
}
return acc;
};