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
301
301
302
302
if ( config . namingConvention ?. enumValues )
303
303
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 } )` ;
306
306
}
307
307
else {
308
308
fieldSchema = `${ fieldSchema } .default("${ escapeGraphQLCharacters ( defaultValue . value ) } ")` ;
Original file line number Diff line number Diff line change @@ -1610,6 +1610,7 @@ describe('yup', () => {
1610
1610
}
1611
1611
input PageInput {
1612
1612
pageType: PageType! = PUBLIC
1613
+ customPageType: PageType! = PUBLIC
1613
1614
greeting: String = "Hello"
1614
1615
score: Int = 100
1615
1616
ratio: Float = 0.5
@@ -1633,6 +1634,7 @@ describe('yup', () => {
1633
1634
expect ( result . content ) . toContain ( 'export function PageInputSchema(): yup.ObjectSchema<PageInput>' ) ;
1634
1635
1635
1636
expect ( result . content ) . toContain ( 'pageType: PageTypeSchema.nonNullable().default(PageType.Public)' ) ;
1637
+ expect ( result . content ) . toContain ( 'customPageType: PageTypeSchema.nonNullable().default(PageType.Public)' ) ;
1636
1638
expect ( result . content ) . toContain ( 'greeting: yup.string().defined().nullable().default("Hello").optional()' ) ;
1637
1639
expect ( result . content ) . toContain ( 'score: yup.number().defined().nullable().default(100).optional()' ) ;
1638
1640
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