@@ -30,19 +30,12 @@ import {
30
30
describe ( 'findBreakingChanges' , ( ) => {
31
31
it ( 'should detect if a type was removed or not' , ( ) => {
32
32
const oldSchema = buildSchema ( `
33
- type Type1 {
34
- field1: String
35
- }
36
-
37
- type Type2 {
38
- field1: String
39
- }
33
+ type Type1
34
+ type Type2
40
35
` ) ;
41
36
42
37
const newSchema = buildSchema ( `
43
- type Type2 {
44
- field1: String
45
- }
38
+ type Type2
46
39
` ) ;
47
40
expect ( findBreakingChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
48
41
{
@@ -55,17 +48,11 @@ describe('findBreakingChanges', () => {
55
48
56
49
it ( 'should detect if a type changed its type' , ( ) => {
57
50
const oldSchema = buildSchema ( `
58
- interface Type1 {
59
- field1: String
60
- }
51
+ interface Type1
61
52
` ) ;
62
53
63
54
const newSchema = buildSchema ( `
64
- type ObjectType {
65
- field1: String
66
- }
67
-
68
- union Type1 = ObjectType
55
+ union Type1
69
56
` ) ;
70
57
expect ( findBreakingChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
71
58
{
@@ -77,9 +64,8 @@ describe('findBreakingChanges', () => {
77
64
78
65
it ( 'should detect if a field on a type was deleted or changed type' , ( ) => {
79
66
const oldSchema = buildSchema ( `
80
- type TypeA {
81
- field1: String
82
- }
67
+ type TypeA
68
+ type TypeB
83
69
84
70
interface Type1 {
85
71
field1: TypeA
@@ -103,13 +89,8 @@ describe('findBreakingChanges', () => {
103
89
` ) ;
104
90
105
91
const newSchema = buildSchema ( `
106
- type TypeA {
107
- field1: String
108
- }
109
-
110
- type TypeB {
111
- field1: String
112
- }
92
+ type TypeA
93
+ type TypeB
113
94
114
95
interface Type1 {
115
96
field1: TypeA
@@ -305,32 +286,16 @@ describe('findBreakingChanges', () => {
305
286
306
287
it ( 'should detect if a type was removed from a union type' , ( ) => {
307
288
const oldSchema = buildSchema ( `
308
- type Type1 {
309
- field1: String
310
- }
311
-
312
- type Type2 {
313
- field1: String
314
- }
315
-
316
- type Type3 {
317
- field1: String
318
- }
289
+ type Type1
290
+ type Type2
291
+ type Type3
319
292
320
293
union UnionType1 = Type1 | Type2
321
294
` ) ;
322
295
const newSchema = buildSchema ( `
323
- type Type1 {
324
- field1: String
325
- }
326
-
327
- type Type2 {
328
- field1: String
329
- }
330
-
331
- type Type3 {
332
- field1: String
333
- }
296
+ type Type1
297
+ type Type2
298
+ type Type3
334
299
335
300
union UnionType1 = Type1 | Type3
336
301
` ) ;
@@ -582,23 +547,15 @@ describe('findBreakingChanges', () => {
582
547
583
548
it ( 'should detect interfaces removed from types' , ( ) => {
584
549
const oldSchema = buildSchema ( `
585
- interface Interface1 {
586
- field1: String
587
- }
550
+ interface Interface1
588
551
589
- type Type1 implements Interface1 {
590
- field1: String
591
- }
552
+ type Type1 implements Interface1
592
553
` ) ;
593
554
594
555
const newSchema = buildSchema ( `
595
- interface Interface1 {
596
- field1: String
597
- }
556
+ interface Interface1
598
557
599
- type Type1 {
600
- field1: String
601
- }
558
+ type Type1
602
559
` ) ;
603
560
604
561
expect ( findBreakingChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
@@ -629,31 +586,16 @@ describe('findBreakingChanges', () => {
629
586
VALUE2
630
587
}
631
588
632
- interface Interface1 {
633
- field1: String
634
- }
635
-
636
- type TypeThatGainsInterface1 implements Interface1 {
637
- field1: String
638
- }
639
-
640
- type TypeInUnion1 {
641
- field1: String
642
- }
643
-
644
- type TypeInUnion2 {
645
- field1: String
646
- }
589
+ interface Interface1
590
+ type TypeThatLooseInterface1 implements Interface1
647
591
592
+ type TypeInUnion1
593
+ type TypeInUnion2
648
594
union UnionTypeThatLosesAType = TypeInUnion1 | TypeInUnion2
649
595
650
- type TypeThatChangesType {
651
- field1: String
652
- }
596
+ type TypeThatChangesType
653
597
654
- type TypeThatGetsRemoved {
655
- field1: String
656
- }
598
+ type TypeThatGetsRemoved
657
599
658
600
interface TypeThatHasBreakingFieldChanges {
659
601
field1: String
@@ -677,23 +619,14 @@ describe('findBreakingChanges', () => {
677
619
VALUE2
678
620
}
679
621
680
- interface Interface1 {
681
- field1: String
682
- }
683
-
684
- type TypeInUnion1 {
685
- field1: String
686
- }
622
+ interface Interface1
623
+ type TypeThatLooseInterface1
687
624
625
+ type TypeInUnion1
626
+ type TypeInUnion2
688
627
union UnionTypeThatLosesAType = TypeInUnion1
689
628
690
- interface TypeThatChangesType {
691
- field1: String
692
- }
693
-
694
- type TypeThatGainsInterface1 {
695
- field1: String
696
- }
629
+ interface TypeThatChangesType
697
630
698
631
interface TypeThatHasBreakingFieldChanges {
699
632
field2: Boolean
@@ -705,10 +638,6 @@ describe('findBreakingChanges', () => {
705
638
type : BreakingChangeType . TYPE_REMOVED ,
706
639
description : 'Int was removed.' ,
707
640
} ,
708
- {
709
- type : BreakingChangeType . TYPE_REMOVED ,
710
- description : 'TypeInUnion2 was removed.' ,
711
- } ,
712
641
{
713
642
type : BreakingChangeType . TYPE_REMOVED ,
714
643
description : 'TypeThatGetsRemoved was removed.' ,
@@ -745,7 +674,7 @@ describe('findBreakingChanges', () => {
745
674
{
746
675
type : BreakingChangeType . INTERFACE_REMOVED_FROM_OBJECT ,
747
676
description :
748
- 'TypeThatGainsInterface1 no longer implements interface Interface1.' ,
677
+ 'TypeThatLooseInterface1 no longer implements interface Interface1.' ,
749
678
} ,
750
679
{
751
680
type : BreakingChangeType . DIRECTIVE_REMOVED ,
@@ -905,19 +834,15 @@ describe('findDangerousChanges', () => {
905
834
906
835
it ( 'should detect interfaces added to types' , ( ) => {
907
836
const oldSchema = buildSchema ( `
908
- type Type1 {
909
- field1: String
910
- }
837
+ interface Interface1
838
+
839
+ type Type1
911
840
` ) ;
912
841
913
842
const newSchema = buildSchema ( `
914
- interface Interface1 {
915
- field1: String
916
- }
843
+ interface Interface1
917
844
918
- type Type1 implements Interface1 {
919
- field1: String
920
- }
845
+ type Type1 implements Interface1
921
846
` ) ;
922
847
923
848
expect ( findDangerousChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
@@ -930,21 +855,15 @@ describe('findDangerousChanges', () => {
930
855
931
856
it ( 'should detect if a type was added to a union type' , ( ) => {
932
857
const oldSchema = buildSchema ( `
933
- type Type1 {
934
- field1: String
935
- }
858
+ type Type1
859
+ type Type2
936
860
937
861
union UnionType1 = Type1
938
862
` ) ;
939
863
940
864
const newSchema = buildSchema ( `
941
- type Type1 {
942
- field1: String
943
- }
944
-
945
- type Type2 {
946
- field1: String
947
- }
865
+ type Type1
866
+ type Type2
948
867
949
868
union UnionType1 = Type1 | Type2
950
869
` ) ;
@@ -988,17 +907,13 @@ describe('findDangerousChanges', () => {
988
907
}
989
908
990
909
type Type1 {
991
- field1(name : String = "test"): String
910
+ field1(argThatChangesDefaultValue : String = "test"): String
992
911
}
993
912
994
- type TypeThatGainsInterface1 {
995
- field1: String
996
- }
997
-
998
- type TypeInUnion1 {
999
- field1: String
1000
- }
913
+ interface Interface1
914
+ type TypeThatGainsInterface1
1001
915
916
+ type TypeInUnion1
1002
917
union UnionTypeThatGainsAType = TypeInUnion1
1003
918
` ) ;
1004
919
@@ -1009,32 +924,22 @@ describe('findDangerousChanges', () => {
1009
924
VALUE2
1010
925
}
1011
926
1012
- interface Interface1 {
1013
- field1: String
1014
- }
1015
-
1016
- type TypeThatGainsInterface1 implements Interface1 {
1017
- field1: String
1018
- }
1019
-
1020
927
type Type1 {
1021
- field1(name : String = "Test"): String
928
+ field1(argThatChangesDefaultValue : String = "Test"): String
1022
929
}
1023
930
1024
- type TypeInUnion1 {
1025
- field1: String
1026
- }
1027
-
1028
- type TypeInUnion2 {
1029
- field1: String
1030
- }
931
+ interface Interface1
932
+ type TypeThatGainsInterface1 implements Interface1
1031
933
934
+ type TypeInUnion1
935
+ type TypeInUnion2
1032
936
union UnionTypeThatGainsAType = TypeInUnion1 | TypeInUnion2
1033
937
` ) ;
1034
938
1035
939
expect ( findDangerousChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
1036
940
{
1037
- description : 'Type1.field1 arg name has changed defaultValue' ,
941
+ description :
942
+ 'Type1.field1 arg argThatChangesDefaultValue has changed defaultValue' ,
1038
943
type : 'ARG_DEFAULT_VALUE_CHANGE' ,
1039
944
} ,
1040
945
{
0 commit comments