File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -301,8 +301,8 @@ function shapeFields(fields: readonly (FieldDefinitionNode | InputValueDefinitio
301301
302302 if ( config . namingConvention ?. enumValues )
303303 value = convertNameParts ( defaultValue . value , resolveExternalModuleAndFn ( config . namingConvention ?. enumValues ) , config ?. namingConvention ?. transformUnderscore ) ;
304-
305- fieldSchema = `${ fieldSchema } .default(${ visitor . convertName ( field . name . value ) } .${ value } )` ;
304+ const enumName = field . type ?. type ?. name . value ?? field . name . value
305+ fieldSchema = `${ fieldSchema } .default(${ visitor . convertName ( enumName ) } .${ value } )` ;
306306 }
307307 else {
308308 fieldSchema = `${ fieldSchema } .default("${ escapeGraphQLCharacters ( defaultValue . value ) } ")` ;
Original file line number Diff line number Diff line change @@ -1610,6 +1610,7 @@ describe('yup', () => {
16101610 }
16111611 input PageInput {
16121612 pageType: PageType! = PUBLIC
1613+ customPageType: PageType! = PUBLIC
16131614 greeting: String = "Hello"
16141615 score: Int = 100
16151616 ratio: Float = 0.5
@@ -1633,6 +1634,7 @@ describe('yup', () => {
16331634 expect ( result . content ) . toContain ( 'export function PageInputSchema(): yup.ObjectSchema<PageInput>' ) ;
16341635
16351636 expect ( result . content ) . toContain ( 'pageType: PageTypeSchema.nonNullable().default(PageType.Public)' ) ;
1637+ expect ( result . content ) . toContain ( 'customPageType: PageTypeSchema.nonNullable().default(PageType.Public)' ) ;
16361638 expect ( result . content ) . toContain ( 'greeting: yup.string().defined().nullable().default("Hello").optional()' ) ;
16371639 expect ( result . content ) . toContain ( 'score: yup.number().defined().nullable().default(100).optional()' ) ;
16381640 expect ( result . content ) . toContain ( 'ratio: yup.number().defined().nullable().default(0.5).optional()' ) ;
You can’t perform that action at this time.
0 commit comments