@@ -244,7 +244,7 @@ def should_detect_if_fields_on_input_types_changed_kind_or_were_removed():
244
244
assert find_fields_that_changed_type_on_input_object_types (
245
245
old_schema , new_schema ).breaking_changes == expected_field_changes
246
246
247
- def should_detect_if_a_non_null_field_is_added_to_an_input_type ():
247
+ def should_detect_if_a_required_field_is_added_to_an_input_type ():
248
248
old_schema = build_schema ("""
249
249
input InputType1 {
250
250
field1: String
@@ -259,7 +259,8 @@ def should_detect_if_a_non_null_field_is_added_to_an_input_type():
259
259
input InputType1 {
260
260
field1: String
261
261
requiredField: Int!
262
- optionalField: Boolean
262
+ optionalField1: Boolean
263
+ optionalField2: Boolean! = false
263
264
}
264
265
265
266
type Query {
@@ -268,8 +269,8 @@ def should_detect_if_a_non_null_field_is_added_to_an_input_type():
268
269
""" )
269
270
270
271
expected_field_changes = [
271
- (BreakingChangeType .NON_NULL_INPUT_FIELD_ADDED ,
272
- 'A non-null field requiredField on input type'
272
+ (BreakingChangeType .REQUIRED_INPUT_FIELD_ADDED ,
273
+ 'A required field requiredField on input type'
273
274
' InputType1 was added.' )]
274
275
275
276
assert find_fields_that_changed_type_on_input_object_types (
@@ -462,7 +463,7 @@ def should_detect_if_a_field_argument_has_changed_type():
462
463
'Type1.field1 arg arg15 has changed type from [[Int]!]'
463
464
' to [[Int!]!]' )]
464
465
465
- def should_detect_if_a_non_null_field_argument_was_added ():
466
+ def should_detect_if_a_required_field_argument_was_added ():
466
467
old_schema = build_schema ("""
467
468
type Type1 {
468
469
field1(arg1: String): String
@@ -475,7 +476,12 @@ def should_detect_if_a_non_null_field_argument_was_added():
475
476
476
477
new_schema = build_schema ("""
477
478
type Type1 {
478
- field1(arg1: String, newRequiredArg: String!, newOptionalArg: Int): String
479
+ field1(
480
+ arg1: String,
481
+ newRequiredArg: String!
482
+ newOptionalArg1: Int
483
+ newOptionalArg2: Int! = 0
484
+ ): String
479
485
}
480
486
481
487
type Query {
@@ -484,8 +490,8 @@ def should_detect_if_a_non_null_field_argument_was_added():
484
490
""" ) # noqa
485
491
486
492
assert find_arg_changes (old_schema , new_schema ).breaking_changes == [
487
- (BreakingChangeType .NON_NULL_ARG_ADDED ,
488
- 'A non-null arg newRequiredArg on Type1.field1 was added' )]
493
+ (BreakingChangeType .REQUIRED_ARG_ADDED ,
494
+ 'A required arg newRequiredArg on Type1.field1 was added' )]
489
495
490
496
def should_not_flag_args_with_the_same_type_signature_as_breaking ():
491
497
old_schema = build_schema ("""
@@ -700,8 +706,8 @@ def should_detect_all_breaking_changes():
700
706
'DirectiveThatIsRemoved was removed' ),
701
707
(BreakingChangeType .DIRECTIVE_ARG_REMOVED ,
702
708
'arg1 was removed from DirectiveThatRemovesArg' ),
703
- (BreakingChangeType .NON_NULL_DIRECTIVE_ARG_ADDED ,
704
- 'A non-null arg arg1 on directive'
709
+ (BreakingChangeType .REQUIRED_DIRECTIVE_ARG_ADDED ,
710
+ 'A required arg arg1 on directive'
705
711
' NonNullDirectiveAdded was added' ),
706
712
(BreakingChangeType .DIRECTIVE_LOCATION_REMOVED ,
707
713
'QUERY was removed from DirectiveName' )]
@@ -746,18 +752,22 @@ def should_detect_if_a_directive_argument_was_removed():
746
752
(BreakingChangeType .DIRECTIVE_ARG_REMOVED ,
747
753
'arg1 was removed from DirectiveWithArg' )]
748
754
749
- def should_detect_if_a_non_nullable_directive_argument_was_added ():
755
+ def should_detect_if_an_optional_directive_argument_was_added ():
750
756
old_schema = build_schema ("""
751
757
directive @DirectiveName on FIELD_DEFINITION
752
758
""" )
753
759
754
760
new_schema = build_schema ("""
755
- directive @DirectiveName(arg1: Boolean!) on FIELD_DEFINITION
761
+ directive @DirectiveName(
762
+ newRequiredArg: String!
763
+ newOptionalArg1: Int
764
+ newOptionalArg2: Int! = 0
765
+ ) on FIELD_DEFINITION
756
766
""" )
757
767
758
768
assert find_added_non_null_directive_args (old_schema , new_schema ) == [
759
- (BreakingChangeType .NON_NULL_DIRECTIVE_ARG_ADDED ,
760
- 'A non-null arg arg1 on directive DirectiveName was added' )]
769
+ (BreakingChangeType .REQUIRED_DIRECTIVE_ARG_ADDED , 'A required arg'
770
+ ' newRequiredArg on directive DirectiveName was added' )]
761
771
762
772
def should_detect_locations_removed_from_a_directive ():
763
773
d1 = GraphQLDirective ('Directive Name' , locations = [
@@ -904,7 +914,7 @@ def should_detect_if_a_type_was_added_to_a_union_type():
904
914
(DangerousChangeType .TYPE_ADDED_TO_UNION ,
905
915
'Type2 was added to union type UnionType1.' )]
906
916
907
- def should_detect_if_a_nullable_field_was_added_to_an_input ():
917
+ def should_detect_if_an_optional_field_was_added_to_an_input ():
908
918
old_schema = build_schema ("""
909
919
input InputType1 {
910
920
field1: String
@@ -927,8 +937,8 @@ def should_detect_if_a_nullable_field_was_added_to_an_input():
927
937
""" )
928
938
929
939
expected_field_changes = [
930
- (DangerousChangeType .NULLABLE_INPUT_FIELD_ADDED ,
931
- 'A nullable field field2 on input type InputType1 was added.' )]
940
+ (DangerousChangeType .OPTIONAL_INPUT_FIELD_ADDED ,
941
+ 'An optional field field2 on input type InputType1 was added.' )]
932
942
933
943
assert find_fields_that_changed_type_on_input_object_types (
934
944
old_schema , new_schema ).dangerous_changes == expected_field_changes
@@ -1007,7 +1017,7 @@ def should_find_all_dangerous_changes():
1007
1017
assert find_dangerous_changes (
1008
1018
old_schema , new_schema ) == expected_dangerous_changes
1009
1019
1010
- def should_detect_if_a_nullable_field_argument_was_added ():
1020
+ def should_detect_if_an_optional_field_argument_was_added ():
1011
1021
old_schema = build_schema ("""
1012
1022
type Type1 {
1013
1023
field1(arg1: String): String
@@ -1029,5 +1039,5 @@ def should_detect_if_a_nullable_field_argument_was_added():
1029
1039
""" )
1030
1040
1031
1041
assert find_arg_changes (old_schema , new_schema ).
1CF5
dangerous_changes == [
1032
- (DangerousChangeType .NULLABLE_ARG_ADDED ,
1033
- 'A nullable arg arg2 on Type1.field1 was added' )]
1042
+ (DangerousChangeType .OPTIONAL_ARG_ADDED ,
1043
+ 'An optional arg arg2 on Type1.field1 was added' )]
0 commit comments