This PR was created by [GitStart](https://gitstart.com/) to address the requirements from this ticket: [TWNTY-6980](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-6980). This ticket was imported from: [TWNTY-6980](https://github.com/twentyhq/twenty/issues/6980) --- ### Description - **fix**: added a transformation step that prefixes the newly added option with an underscore before the Graphql enum is generated so it saves successfully and passes the default GraphQL validation. ### Demo - <https://www.loom.com/share/feda2198ed8b4e558f96520a0d051725> ### Refs #6980 Fixes #6980 Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: Weiko <corentin@twenty.com>
15 lines
370 B
TypeScript
15 lines
370 B
TypeScript
import { FieldMetadataDefaultOption } from 'src/engine/metadata-modules/field-metadata/dtos/options.input';
|
|
|
|
export function transformEnumValue(options?: FieldMetadataDefaultOption[]) {
|
|
return options?.map((option) => {
|
|
if (/^\d/.test(option.value)) {
|
|
return {
|
|
...option,
|
|
value: `_${option.value}`,
|
|
};
|
|
}
|
|
|
|
return option;
|
|
});
|
|
}
|