@@ -15,6 +15,7 @@ import {
15
15
Kind ,
16
16
} from 'graphql' ;
17
17
18
+ import { resolveExternalModuleAndFn } from '@graphql-codegen/plugin-helpers' ;
18
19
import type { ValidationSchemaPluginConfig } from '../config' ;
19
20
import { buildApi , formatDirectiveConfig } from '../directive' ;
20
21
import { BaseSchemaVisitor } from '../schema_visitor' ;
@@ -27,7 +28,6 @@ import {
27
28
isNamedType ,
28
29
isNonNullType ,
29
30
} from './../graphql' ;
30
- import { resolveExternalModuleAndFn } from '@graphql-codegen/plugin-helpers' ;
31
31
32
32
export class YupSchemaVisitor extends BaseSchemaVisitor {
33
33
constructor ( schema : GraphQLSchema , config : ValidationSchemaPluginConfig ) {
@@ -280,20 +280,19 @@ function shapeFields(fields: readonly (FieldDefinitionNode | InputValueDefinitio
280
280
defaultValue ?. kind === Kind . INT
281
281
|| defaultValue ?. kind === Kind . FLOAT
282
282
|| defaultValue ?. kind === Kind . BOOLEAN
283
- ) {
283
+ )
284
284
fieldSchema = `${ fieldSchema } .default(${ defaultValue . value } )` ;
285
- }
286
285
287
286
if ( defaultValue ?. kind === Kind . STRING || defaultValue ?. kind === Kind . ENUM ) {
288
287
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' ) ) ;
290
289
291
- if ( config . namingConvention ?. enumValues ) {
290
+ if ( config . namingConvention ?. enumValues )
292
291
value = convertNameParts ( defaultValue . value , resolveExternalModuleAndFn ( config . namingConvention ?. enumValues ) ) ;
293
- }
294
292
295
293
fieldSchema = `${ fieldSchema } .default(${ visitor . convertName ( field . name . value ) } .${ value } )` ;
296
- } else {
294
+ }
295
+ else {
297
296
fieldSchema = `${ fieldSchema } .default("${ defaultValue . value } ")` ;
298
297
}
299
298
}
0 commit comments