@@ -437,15 +437,7 @@ function isChangeSafeForObjectOrInterfaceField(
437
437
oldType : GraphQLType ,
438
438
newType : GraphQLType ,
439
439
) : boolean {
440
- if ( isNamedType ( oldType ) ) {
441
- return (
442
- // if they're both named types, see if their names are equivalent
443
- ( isNamedType ( newType ) && oldType . name === newType . name ) ||
444
- // moving from nullable to non-null of the same underlying type is safe
445
- ( isNonNullType ( newType ) &&
446
- isChangeSafeForObjectOrInterfaceField ( oldType , newType . ofType ) )
447
- ) ;
448
- } else if ( isListType ( oldType ) ) {
440
+ if ( isListType ( oldType ) ) {
449
441
return (
450
442
// if they're both lists, make sure the underlying types are compatible
451
443
( isListType ( newType ) &&
@@ -457,30 +449,38 @@ function isChangeSafeForObjectOrInterfaceField(
457
449
( isNonNullType ( newType ) &&
458
450
isChangeSafeForObjectOrInterfaceField ( oldType , newType . ofType ) )
459
451
) ;
460
- } else if ( isNonNullType ( oldType ) ) {
452
+ }
453
+
454
+ if ( isNonNullType ( oldType ) ) {
461
455
// if they're both non-null, make sure the underlying types are compatible
462
456
return (
463
457
isNonNullType ( newType ) &&
464
458
isChangeSafeForObjectOrInterfaceField ( oldType . ofType , newType . ofType )
465
459
) ;
466
460
}
467
- return false ;
461
+
462
+ return (
463
+ // if they're both named types, see if their names are equivalent
464
+ ( isNamedType ( newType ) && oldType . name === newType . name ) ||
465
+ // moving from nullable to non-null of the same underlying type is safe
466
+ ( isNonNullType ( newType ) &&
467
+ isChangeSafeForObjectOrInterfaceField ( oldType , newType . ofType ) )
468
+ ) ;
468
469
}
469
470
470
471
function isChangeSafeForInputObjectFieldOrFieldArg (
471
472
oldType : GraphQLType ,
472
473
newType : GraphQLType ,
473
474
) : boolean {
474
- if ( isNamedType ( oldType ) ) {
475
- // if they're both named types, see if their names are equivalent
476
- return isNamedType ( newType ) && oldType . name === newType . name ;
477
- } else if ( isListType ( oldType ) ) {
475
+ if ( isListType ( oldType ) ) {
478
476
// if they're both lists, make sure the underlying types are compatible
479
477
return (
480
478
isListType ( newType ) &&
481
479
isChangeSafeForInputObjectFieldOrFieldArg ( oldType . ofType , newType . ofType )
482
480
) ;
483
- } else if ( isNonNullType ( oldType ) ) {
481
+ }
482
+
483
+ if ( isNonNullType ( oldType ) ) {
484
484
return (
485
485
// if they're both non-null, make sure the underlying types are
486
486
// compatible
@@ -494,7 +494,9 @@ function isChangeSafeForInputObjectFieldOrFieldArg(
494
494
isChangeSafeForInputObjectFieldOrFieldArg ( oldType . ofType , newType ) )
495
495
) ;
496
496
}
497
- return false ;
497
+
498
+ // if they're both named types, see if their names are equivalent
499
+ return isNamedType ( newType ) && oldType . name === newType . name ;
498
500
}
499
501
500
502
/**
0 commit comments