@@ -333,7 +333,7 @@ describe('findBreakingChanges', () => {
333
333
) . to . eql ( expectedFieldChanges ) ;
334
334
} ) ;
335
335
336
- it ( 'should detect if a non-null field is added to an input type' , ( ) => {
336
+ it ( 'should detect if a required field is added to an input type' , ( ) => {
337
337
const oldSchema = buildSchema ( `
338
338
input InputType1 {
339
339
field1: String
@@ -348,7 +348,8 @@ describe('findBreakingChanges', () => {
348
348
input InputType1 {
349
349
field1: String
350
350
requiredField: Int!
351
- optionalField: Boolean
351
+ optionalField1: Boolean
352
+ optionalField2: Boolean! = false
352
353
}
353
354
354
355
type Query {
@@ -358,10 +359,9 @@ describe('findBreakingChanges', () => {
358
359
359
360
const expectedFieldChanges = [
360
361
{
361
- type : BreakingChangeType . NON_NULL_INPUT_FIELD_ADDED ,
362
+ type : BreakingChangeType . REQUIRED_INPUT_FIELD_ADDED ,
362
363
description :
363
- 'A non-null field requiredField on input type ' +
364
- 'InputType1 was added.' ,
364
+ 'A required field requiredField on input type InputType1 was added.' ,
365
365
} ,
366
366
] ;
367
367
expect (
@@ -609,7 +609,7 @@ describe('findBreakingChanges', () => {
609
609
] ) ;
610
610
} ) ;
611
611
612
- it ( 'should detect if a non-null field argument was added' , ( ) => {
612
+ it ( 'should detect if a required field argument was added' , ( ) => {
613
613
const oldSchema = buildSchema ( `
614
614
type Type1 {
615
615
field1(arg1: String): String
@@ -622,7 +622,12 @@ describe('findBreakingChanges', () => {
622
622
623
623
const newSchema = buildSchema ( `
624
624
type Type1 {
625
- field1(arg1: String, newRequiredArg: String!, newOptionalArg: Int): String
625
+ field1(
626
+ arg1: String,
627
+ newRequiredArg: String!
628
+ newOptionalArg1: Int
629
+ newOptionalArg2: Int! = 0
630
+ ): String
626
631
}
627
632
628
633
type Query {
@@ -632,8 +637,8 @@ describe('findBreakingChanges', () => {
632
637
633
638
expect ( findArgChanges ( oldSchema , newSchema ) . breakingChanges ) . to . eql ( [
634
639
{
635
- type : BreakingChangeType . NON_NULL_ARG_ADDED ,
636
- description : 'A non-null arg newRequiredArg on Type1.field1 was added' ,
640
+ type : BreakingChangeType . REQUIRED_ARG_ADDED ,
641
+ description : 'A required arg newRequiredArg on Type1.field1 was added' ,
637
642
} ,
638
643
] ) ;
639
644
} ) ;
@@ -882,9 +887,9 @@ describe('findBreakingChanges', () => {
882
887
description : 'arg1 was removed from DirectiveThatRemovesArg' ,
883
888
} ,
884
889
{
885
- type : BreakingChangeType . NON_NULL_DIRECTIVE_ARG_ADDED ,
890
+ type : BreakingChangeType . REQUIRED_DIRECTIVE_ARG_ADDED ,
886
891
description :
887
- 'A non-null arg arg1 on directive NonNullDirectiveAdded was added' ,
892
+ 'A required arg arg1 on directive NonNullDirectiveAdded was added' ,
888
893
} ,
889
894
{
890
895
type : BreakingChangeType . DIRECTIVE_LOCATION_REMOVED ,
@@ -946,19 +951,24 @@ describe('findBreakingChanges', () => {
946
951
] ) ;
947
952
} ) ;
948
953
949
- it ( 'should detect if a non-nullable directive argument was added' , ( ) => {
954
+ it ( 'should detect if an optional directive argument was added' , ( ) => {
950
955
const oldSchema = buildSchema ( `
951
956
directive @DirectiveName on FIELD_DEFINITION
952
957
` ) ;
953
958
954
959
const newSchema = buildSchema ( `
955
- directive @DirectiveName(arg1: Boolean!) on FIELD_DEFINITION
960
+ directive @DirectiveName(
961
+ newRequiredArg: String!
962
+ newOptionalArg1: Int
963
+ newOptionalArg2: Int! = 0
964
+ ) on FIELD_DEFINITION
956
965
` ) ;
957
966
958
967
expect ( findAddedNonNullDirectiveArgs ( oldSchema , newSchema ) ) . to . eql ( [
959
968
{
960
- type : BreakingChangeType . NON_NULL_DIRECTIVE_ARG_ADDED ,
961
- description : 'A non-null arg arg1 on directive DirectiveName was added' ,
969
+ type : BreakingChangeType . REQUIRED_DIRECTIVE_ARG_ADDED ,
970
+ description :
971
+ 'A required arg newRequiredArg on directive DirectiveName was added' ,
962
972
} ,
963
973
] ) ;
964
974
} ) ;
@@ -1131,7 +1141,7 @@ describe('findDangerousChanges', () => {
1131
1141
] ) ;
1132
1142
} ) ;
1133
1143
1134
- it ( 'should detect if a nullable field was added to an input' , ( ) => {
1144
+ it ( 'should detect if an optional field was added to an input' , ( ) => {
1135
1145
const oldSchema = buildSchema ( `
1136
1146
input InputType1 {
1137
1147
field1: String
@@ -1155,9 +1165,9 @@ describe('findDangerousChanges', () => {
1155
1165
1156
1166
const expectedFieldChanges = [
1157
1167
{
1158
- type : DangerousChangeType . NULLABLE_INPUT_FIELD_ADDED ,
1168
+ type : DangerousChangeType . OPTIONAL_INPUT_FIELD_ADDED ,
1159
1169
description :
1160
- 'A nullable field field2 on input type InputType1 was added.' ,
1170
+ 'An optional field field2 on input type InputType1 was added.' ,
1161
1171
} ,
1162
1172
] ;
1163
1173
@@ -1253,7 +1263,7 @@ describe('findDangerousChanges', () => {
1253
1263
) ;
1254
1264
} ) ;
1255
1265
1256
- it ( 'should detect if a nullable field argument was added' , ( ) => {
1266
+ it ( 'should detect if an optional field argument was added' , ( ) => {
1257
1267
const oldSchema = buildSchema ( `
1258
1268
type Type1 {
1259
1269
field1(arg1: String): String
@@ -1276,8 +1286,8 @@ describe('findDangerousChanges', () => {
1276
1286
1277
1287
expect ( findArgChanges ( oldSchema , newSchema ) . dangerousChanges ) . to . eql ( [
1278
1288
{
1279
- type : DangerousChangeType . NULLABLE_ARG_ADDED ,
1280
- description : 'A nullable arg arg2 on Type1.field1 was added' ,
1289
+ type : DangerousChangeType . OPTIONAL_ARG_ADDED ,
1290
+ description : 'An optional arg arg2 on Type1.field1 was added' ,
1281
1291
} ,
1282
1292
] ) ;
1283
1293
} ) ;
0 commit comments