@@ -69,7 +69,7 @@ export class YupSchemaVisitor extends BaseSchemaVisitor {
69
69
const appendArguments = argumentBlocks ? '\n' + argumentBlocks : '' ;
70
70
71
71
// Building schema for fields.
72
- const shape = shapeFields ( node . fields , this . config , visitor )
72
+ const shape = shapeFields ( node . fields , this . config , visitor ) ;
73
73
74
74
switch ( this . config . validationSchemaExportType ) {
75
75
case 'const' :
@@ -199,7 +199,7 @@ export class YupSchemaVisitor extends BaseSchemaVisitor {
199
199
visitor : Visitor ,
200
200
name : string
201
201
) {
202
- const shape = shapeFields ( fields , this . config , visitor )
202
+ const shape = shapeFields ( fields , this . config , visitor ) ;
203
203
204
204
switch ( this . config . validationSchemaExportType ) {
205
205
case 'const' :
@@ -220,29 +220,38 @@ export class YupSchemaVisitor extends BaseSchemaVisitor {
220
220
}
221
221
}
222
222
223
- const shapeFields = ( fields : readonly ( FieldDefinitionNode | InputValueDefinitionNode ) [ ] | undefined , config : ValidationSchemaPluginConfig , visitor : Visitor ) => {
224
- return fields ?. map ( field => {
225
- let fieldSchema = generateFieldYupSchema ( config , visitor , field , 2 ) ;
223
+ const shapeFields = (
224
+ fields : readonly ( FieldDefinitionNode | InputValueDefinitionNode ) [ ] | undefined ,
225
+ config : ValidationSchemaPluginConfig ,
226
+ visitor : Visitor
227
+ ) => {
228
+ return fields
229
+ ?. map ( field => {
230
+ let fieldSchema = generateFieldYupSchema ( config , visitor , field , 2 ) ;
226
231
227
- if ( field . kind === Kind . INPUT_VALUE_DEFINITION ) {
228
- const { defaultValue } = field ;
232
+ if ( field . kind === Kind . INPUT_VALUE_DEFINITION ) {
233
+ const { defaultValue } = field ;
229
234
230
- if ( defaultValue ?. kind === Kind . INT || defaultValue ?. kind === Kind . FLOAT || defaultValue ?. kind === Kind . BOOLEAN ) {
231
- fieldSchema = `${ fieldSchema } .default(${ defaultValue . value } )` ;
232
- }
233
- if ( ( defaultValue ?. kind === Kind . STRING ) || ( defaultValue ?. kind === Kind . ENUM ) ) {
234
- fieldSchema = `${ fieldSchema } .default("${ defaultValue . value } ")` ;
235
+ if (
236
+ defaultValue ?. kind === Kind . INT ||
237
+ defaultValue ?. kind === Kind . FLOAT ||
238
+ defaultValue ?. kind === Kind . BOOLEAN
239
+ ) {
240
+ fieldSchema = `${ fieldSchema } .default(${ defaultValue . value } )` ;
241
+ }
242
+ if ( defaultValue ?. kind === Kind . STRING || defaultValue ?. kind === Kind . ENUM ) {
243
+ fieldSchema = `${ fieldSchema } .default("${ defaultValue . value } ")` ;
244
+ }
235
245
}
236
- }
237
246
238
- if ( isNonNullType ( field . type ) ) {
239
- return fieldSchema
240
- }
247
+ if ( isNonNullType ( field . type ) ) {
248
+ return fieldSchema ;
249
+ }
241
250
242
- return `${ fieldSchema } .optional()` ;
243
- } )
244
- . join ( ',\n' ) ;
245
- }
251
+ return `${ fieldSchema } .optional()` ;
252
+ } )
253
+ . join ( ',\n' ) ;
254
+ } ;
246
255
247
256
const generateFieldYupSchema = (
248
257
config : ValidationSchemaPluginConfig ,
0 commit comments