-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bug] Select options names can't start with a number (#7079)
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](#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 <[email protected]> Co-authored-by: Weiko <[email protected]>
- Loading branch information
1 parent
e0ada0a
commit b3ed6cb
Showing
4 changed files
with
24 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/twenty-server/src/engine/utils/transform-enum-value.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
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; | ||
}); | ||
} |