@@ -428,20 +428,7 @@ def find_fields_that_changed_type_on_input_object_types(
428
428
def is_change_safe_for_object_or_interface_field (
429
429
old_type : GraphQLType , new_type : GraphQLType
430
430
) -> bool :
431
- if is_named_type (old_type ):
432
- return (
433
- # if they're both named types, see if their names are equivalent
434
- is_named_type (new_type )
435
- and cast (GraphQLNamedType , old_type ).name
436
- == cast (GraphQLNamedType , new_type ).name
437
- ) or (
438
- # moving from nullable to non-null of same underlying type is safe
439
- is_non_null_type (new_type )
440
- and is_change_safe_for_object_or_interface_field (
441
- old_type , cast (GraphQLNonNull , new_type ).of_type
442
- )
443
- )
444
- elif is_list_type (old_type ):
431
+ if is_list_type (old_type ):
445
432
return (
446
433
# if they're both lists, make sure underlying types are compatible
447
434
is_list_type (new_type )
@@ -455,37 +442,43 @@ def is_change_safe_for_object_or_interface_field(
455
442
old_type , cast (GraphQLNonNull , new_type ).of_type
456
443
)
457
444
)
458
- elif is_non_null_type (old_type ):
445
+
446
+ if is_non_null_type (old_type ):
459
447
# if they're both non-null, make sure underlying types are compatible
460
448
return is_non_null_type (
461
449
new_type
462
450
) and is_change_safe_for_object_or_interface_field (
463
451
cast (GraphQLNonNull , old_type ).of_type ,
464
452
cast (GraphQLNonNull , new_type ).of_type ,
465
453
)
466
- else :
467
- return False
454
+
455
+ return (
456
+ # if they're both named types, see if their names are equivalent
457
+ is_named_type (new_type )
458
+ and cast (GraphQLNamedType , old_type ).name
459
+ == cast (GraphQLNamedType , new_type ).name
460
+ ) or (
461
+ # moving from nullable to non-null of same underlying type is safe
462
+ is_non_null_type (new_type )
463
+ and is_change_safe_for_object_or_interface_field (
464
+ old_type , cast (GraphQLNonNull , new_type ).of_type
465
+ )
466
+ )
468
467
469
468
470
469
def is_change_safe_for_input_object_field_or_field_arg (
471
470
old_type : GraphQLType , new_type : GraphQLType
472
471
) -> bool :
473
- if is_named_type (old_type ):
474
- return (
475
- # if they're both named types, see if their names are equivalent
476
- is_named_type (new_type )
477
- and cast (GraphQLNamedType , old_type ).name
478
- == cast (GraphQLNamedType , new_type ).name
479
- )
480
- elif is_list_type (old_type ):
472
+ if is_list_type (old_type ):
481
473
482
474
return is_list_type (
483
475
# if they're both lists, make sure underlying types are compatible
484
476
new_type
485
477
) and is_change_safe_for_input_object_field_or_field_arg (
486
478
cast (GraphQLList , old_type ).of_type , cast (GraphQLList , new_type ).of_type
487
479
)
488
- elif is_non_null_type (old_type ):
480
+
481
+ if is_non_null_type (old_type ):
489
482
return (
490
483
# if they're both non-null, make sure the underlying types are compatible
491
484
is_non_null_type (new_type )
@@ -500,8 +493,13 @@ def is_change_safe_for_input_object_field_or_field_arg(
500
493
cast (GraphQLNonNull , old_type ).of_type , new_type
501
494
)
502
495
)
503
- else :
504
- return False
496
+
497
+ return (
498
+ # if they're both named types, see if their names are equivalent
499
+ is_named_type (new_type )
500
+ and cast (GraphQLNamedType , old_type ).name
501
+ == cast (GraphQLNamedType , new_type ).name
502
+ )
505
503
506
504
507
505
def find_types_removed_from_unions (
0 commit comments