[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](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>
This commit is contained in:
committed by
GitHub
parent
e0ada0a8ee
commit
b3ed6cb903
@ -3,15 +3,16 @@ import { Injectable, Logger } from '@nestjs/common';
|
||||
import { GraphQLEnumType } from 'graphql';
|
||||
|
||||
import { WorkspaceBuildSchemaOptions } from 'src/engine/api/graphql/workspace-schema-builder/interfaces/workspace-build-schema-optionts.interface';
|
||||
import { ObjectMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/object-metadata.interface';
|
||||
import { FieldMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata.interface';
|
||||
import { ObjectMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/object-metadata.interface';
|
||||
|
||||
import { pascalCase } from 'src/utils/pascal-case';
|
||||
import {
|
||||
FieldMetadataComplexOption,
|
||||
FieldMetadataDefaultOption,
|
||||
} from 'src/engine/metadata-modules/field-metadata/dtos/options.input';
|
||||
import { isEnumFieldMetadataType } from 'src/engine/metadata-modules/field-metadata/utils/is-enum-field-metadata-type.util';
|
||||
import { transformEnumValue } from 'src/engine/utils/transform-enum-value';
|
||||
import { pascalCase } from 'src/utils/pascal-case';
|
||||
|
||||
export interface EnumTypeDefinition {
|
||||
target: string;
|
||||
@ -53,7 +54,7 @@ export class EnumTypeDefinitionFactory {
|
||||
): GraphQLEnumType {
|
||||
// FixMe: It's a hack until Typescript get fixed on union types for reduce function
|
||||
// https://github.com/microsoft/TypeScript/issues/36390
|
||||
const enumOptions = fieldMetadata.options as Array<
|
||||
const enumOptions = transformEnumValue(fieldMetadata.options) as Array<
|
||||
FieldMetadataDefaultOption | FieldMetadataComplexOption
|
||||
>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user