@@ -15,6 +15,7 @@ import {
1515 Kind ,
1616} from 'graphql' ;
1717
18+ import { resolveExternalModuleAndFn } from '@graphql-codegen/plugin-helpers' ;
1819import type { ValidationSchemaPluginConfig } from '../config' ;
1920import { buildApi , formatDirectiveConfig } from '../directive' ;
2021import { BaseSchemaVisitor } from '../schema_visitor' ;
@@ -27,7 +28,6 @@ import {
2728 isNamedType ,
2829 isNonNullType ,
2930} from './../graphql' ;
30- import { resolveExternalModuleAndFn } from '@graphql-codegen/plugin-helpers' ;
3131
3232export class YupSchemaVisitor extends BaseSchemaVisitor {
3333 constructor ( schema : GraphQLSchema , config : ValidationSchemaPluginConfig ) {
@@ -280,20 +280,19 @@ function shapeFields(fields: readonly (FieldDefinitionNode | InputValueDefinitio
280280 defaultValue ?. kind === Kind . INT
281281 || defaultValue ?. kind === Kind . FLOAT
282282 || defaultValue ?. kind === Kind . BOOLEAN
283- ) {
283+ )
284284 fieldSchema = `${ fieldSchema } .default(${ defaultValue . value } )` ;
285- }
286285
287286 if ( defaultValue ?. kind === Kind . STRING || defaultValue ?. kind === Kind . ENUM ) {
288287 if ( config . useEnumTypeAsDefaultValue && defaultValue ?. kind !== Kind . STRING ) {
289- let value = convertNameParts ( defaultValue . value , resolveExternalModuleAndFn ( " change-case-all#pascalCase" ) ) ;
288+ let value = convertNameParts ( defaultValue . value , resolveExternalModuleAndFn ( ' change-case-all#pascalCase' ) ) ;
290289
291- if ( config . namingConvention ?. enumValues ) {
290+ if ( config . namingConvention ?. enumValues )
292291 value = convertNameParts ( defaultValue . value , resolveExternalModuleAndFn ( config . namingConvention ?. enumValues ) ) ;
293- }
294292
295293 fieldSchema = `${ fieldSchema } .default(${ visitor . convertName ( field . name . value ) } .${ value } )` ;
296- } else {
294+ }
295+ else {
297296 fieldSchema = `${ fieldSchema } .default("${ defaultValue . value } ")` ;
298297 }
299298 }
0 commit comments