1- import { DeclarationBlock , indent } from '@graphql-codegen/visitor-plugin-common' ;
1+ import { DeclarationBlock , convertNameParts , indent } from '@graphql-codegen/visitor-plugin-common' ;
22import type {
33 EnumTypeDefinitionNode ,
44 FieldDefinitionNode ,
@@ -14,7 +14,6 @@ import type {
1414import {
1515 Kind ,
1616} from 'graphql' ;
17- import { pascalCase } from "change-case" ;
1817
1918import type { ValidationSchemaPluginConfig } from '../config' ;
2019import { buildApi , formatDirectiveConfig } from '../directive' ;
@@ -28,6 +27,7 @@ import {
2827 isNamedType ,
2928 isNonNullType ,
3029} from './../graphql' ;
30+ import { resolveExternalModuleAndFn } from '@graphql-codegen/plugin-helpers' ;
3131
3232export class YupSchemaVisitor extends BaseSchemaVisitor {
3333 constructor ( schema : GraphQLSchema , config : ValidationSchemaPluginConfig ) {
@@ -285,7 +285,13 @@ function shapeFields(fields: readonly (FieldDefinitionNode | InputValueDefinitio
285285
286286 if ( defaultValue ?. kind === Kind . STRING || defaultValue ?. kind === Kind . ENUM ) {
287287 if ( config . useEnumTypeAsDefaultValue && defaultValue ?. kind !== Kind . STRING ) {
288- fieldSchema = `${ fieldSchema } .default(${ visitor . convertName ( field . name . value ) } .${ pascalCase ( defaultValue . value ) } )` ;
288+ let value = convertNameParts ( defaultValue . value , resolveExternalModuleAndFn ( "change-case-all#pascalCase" ) ) ;
289+
290+ if ( config . namingConvention ?. enumValues ) {
291+ value = convertNameParts ( defaultValue . value , resolveExternalModuleAndFn ( config . namingConvention ?. enumValues ) ) ;
292+ }
293+
294+ fieldSchema = `${ fieldSchema } .default(${ visitor . convertName ( field . name . value ) } .${ value } )` ;
289295 } else {
290296 fieldSchema = `${ fieldSchema } .default("${ defaultValue . value } ")` ;
291297 }
0 commit comments