@@ -244,7 +244,7 @@ def should_detect_if_fields_on_input_types_changed_kind_or_were_removed():
244244 assert find_fields_that_changed_type_on_input_object_types (
245245 old_schema , new_schema ).breaking_changes == expected_field_changes
246246
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 ():
248248 old_schema = build_schema ("""
249249 input InputType1 {
250250 field1: String
@@ -259,7 +259,8 @@ def should_detect_if_a_non_null_field_is_added_to_an_input_type():
259259 input InputType1 {
260260 field1: String
261261 requiredField: Int!
262- optionalField: Boolean
262+ optionalField1: Boolean
263+ optionalField2: Boolean! = false
263264 }
264265
265266 type Query {
@@ -268,8 +269,8 @@ def should_detect_if_a_non_null_field_is_added_to_an_input_type():
268269 """ )
269270
270271 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'
273274 ' InputType1 was added.' )]
274275
275276 assert find_fields_that_changed_type_on_input_object_types (
@@ -462,7 +463,7 @@ def should_detect_if_a_field_argument_has_changed_type():
462463 'Type1.field1 arg arg15 has changed type from [[Int]!]'
463464 ' to [[Int!]!]' )]
464465
465- def should_detect_if_a_non_null_field_argument_was_added ():
466+ def should_detect_if_a_required_field_argument_was_added ():
466467 old_schema = build_schema ("""
467468 type Type1 {
468469 field1(arg1: String): String
@@ -475,7 +476,12 @@ def should_detect_if_a_non_null_field_argument_was_added():
475476
476477 new_schema = build_schema ("""
477478 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
479485 }
480486
481487 type Query {
@@ -484,8 +490,8 @@ def should_detect_if_a_non_null_field_argument_was_added():
484490 """ ) # noqa
485491
486492 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' )]
489495
490496 def should_not_flag_args_with_the_same_type_signature_as_breaking ():
491497 old_schema = build_schema ("""
@@ -700,8 +706,8 @@ def should_detect_all_breaking_changes():
700706 'DirectiveThatIsRemoved was removed' ),
701707 (BreakingChangeType .DIRECTIVE_ARG_REMOVED ,
702708 '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'
705711 ' NonNullDirectiveAdded was added' ),
706712 (BreakingChangeType .DIRECTIVE_LOCATION_REMOVED ,
707713 'QUERY was removed from DirectiveName' )]
@@ -746,18 +752,22 @@ def should_detect_if_a_directive_argument_was_removed():
746752 (BreakingChangeType .DIRECTIVE_ARG_REMOVED ,
747753 'arg1 was removed from DirectiveWithArg' )]
748754
749- def should_detect_if_a_non_nullable_directive_argument_was_added ():
755+ def should_detect_if_an_optional_directive_argument_was_added ():
750756 old_schema = build_schema ("""
751757 directive @DirectiveName on FIELD_DEFINITION
752758 """ )
753759
754760 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
756766 """ )
757767
758768 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' )]
761771
762772 def should_detect_locations_removed_from_a_directive ():
763773 d1 = GraphQLDirective ('Directive Name' , locations = [
@@ -904,7 +914,7 @@ def should_detect_if_a_type_was_added_to_a_union_type():
904914 (DangerousChangeType .TYPE_ADDED_TO_UNION ,
905915 'Type2 was added to union type UnionType1.' )]
906916
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 ():
908918 old_schema = build_schema ("""
909919 input InputType1 {
910920 field1: String
@@ -927,8 +937,8 @@ def should_detect_if_a_nullable_field_was_added_to_an_input():
927937 """ )
928938
929939 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.' )]
932942
933943 assert find_fields_that_changed_type_on_input_object_types (
934944 old_schema , new_schema ).dangerous_changes == expected_field_changes
@@ -1007,7 +1017,7 @@ def should_find_all_dangerous_changes():
10071017 assert find_dangerous_changes (
10081018 old_schema , new_schema ) == expected_dangerous_changes
10091019
1010- def should_detect_if_a_nullable_field_argument_was_added ():
1020+ def should_detect_if_an_optional_field_argument_was_added ():
10111021 old_schema = build_schema ("""
10121022 type Type1 {
10131023 field1(arg1: String): String
@@ -1029,5 +1039,5 @@ def should_detect_if_a_nullable_field_argument_was_added():
10291039 """ )
10301040
10311041 assert find_arg_changes (old_schema , new_schema ).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