@@ -17,21 +17,14 @@ def describe_find_breaking_changes():
17
17
def should_detect_if_a_type_was_removed_or_not ():
18
18
old_schema = build_schema (
19
19
"""
20
- type Type1 {
21
- field1: String
22
- }
23
-
24
- type Type2 {
25
- field1: String
26
- }
20
+ type Type1
21
+ type Type2
27
22
"""
28
23
)
29
24
30
25
new_schema = build_schema (
31
26
"""
32
- type Type2 {
33
- field1: String
34
- }
27
+ type Type2
35
28
"""
36
29
)
37
30
@@ -43,19 +36,13 @@ def should_detect_if_a_type_was_removed_or_not():
43
36
def should_detect_if_a_type_changed_its_type ():
44
37
old_schema = build_schema (
45
38
"""
46
- interface Type1 {
47
- field1: String
48
- }
39
+ interface Type1
49
40
"""
50
41
)
51
42
52
43
new_schema = build_schema (
53
44
"""
54
- type ObjectType {
55
- field1: String
56
- }
57
-
58
- union Type1 = ObjectType
45
+ union Type1
59
46
"""
60
47
)
61
48
@@ -69,9 +56,8 @@ def should_detect_if_a_type_changed_its_type():
69
56
def should_detect_if_a_field_on_type_was_deleted_or_changed_type ():
70
57
old_schema = build_schema (
71
58
"""
72
- type TypeA {
73
- field1: String
74
- }
59
+ type TypeA
60
+ type TypeB
75
61
76
62
interface Type1 {
77
63
field1: TypeA
@@ -97,13 +83,8 @@ def should_detect_if_a_field_on_type_was_deleted_or_changed_type():
97
83
98
84
new_schema = build_schema (
99
85
"""
100
- type TypeA {
101
- field1: String
102
- }
103
-
104
- type TypeB {
105
- field1: String
106
- }
86
+ type TypeA
87
+ type TypeB
107
88
108
89
interface Type1 {
109
90
field1: TypeA
@@ -297,35 +278,19 @@ def should_detect_if_a_required_field_is_added_to_an_input_type():
297
278
def should_detect_if_a_type_was_removed_from_a_union_type ():
298
279
old_schema = build_schema (
299
280
"""
300
- type Type1 {
301
- field1: String
302
- }
303
-
304
- type Type2 {
305
- field1: String
306
- }
307
-
308
- type Type3 {
309
- field1: String
310
- }
281
+ type Type1
282
+ type Type2
283
+ type Type3
311
284
312
285
union UnionType1 = Type1 | Type2
313
286
"""
314
287
)
315
288
316
289
new_schema = build_schema (
317
290
"""
318
- type Type1 {
319
- field1: String
320
- }
321
-
322
- type Type2 {
323
- field1: String
324
- }
325
-
326
- type Type3 {
327
- field1: String
328
- }
291
+ type Type1
292
+ type Type2
293
+ type Type3
329
294
330
295
union UnionType1 = Type1 | Type3
331
296
"""
@@ -578,25 +543,17 @@ def should_consider_args_that_move_away_from_non_null_as_non_breaking():
578
543
def should_detect_interfaces_removed_from_types ():
579
544
old_schema = build_schema (
580
545
"""
581
- interface Interface1 {
582
- field1: String
583
- }
546
+ interface Interface1
584
547
585
- type Type1 implements Interface1 {
586
- field1: String
587
- }
548
+ type Type1 implements Interface1
588
549
"""
589
550
)
590
551
591
552
new_schema = build_schema (
592
553
"""
593
- interface Interface1 {
594
- field1: String
595
- }
554
+ interface Interface1
596
555
597
- type Type1 {
598
- field1: String
599
- }
556
+ type Type1
600
557
"""
601
558
)
602
559
@@ -628,31 +585,16 @@ def should_detect_all_breaking_changes():
628
585
VALUE2
629
586
}
630
587
631
- interface Interface1 {
632
- field1: String
633
- }
634
-
635
- type TypeThatGainsInterface1 implements Interface1 {
636
- field1: String
637
- }
638
-
639
- type TypeInUnion1 {
640
- field1: String
641
- }
642
-
643
- type TypeInUnion2 {
644
- field1: String
645
- }
588
+ interface Interface1
589
+ type TypeThatLoosesInterface1 implements Interface1
646
590
591
+ type TypeInUnion1
592
+ type TypeInUnion2
647
593
union UnionTypeThatLosesAType = TypeInUnion1 | TypeInUnion2
648
594
649
- type TypeThatChangesType {
650
- field1: String
651
- }
595
+ type TypeThatChangesType
652
596
653
- type TypeThatGetsRemoved {
654
- field1: String
655
- }
597
+ type TypeThatGetsRemoved
656
598
657
599
interface TypeThatHasBreakingFieldChanges {
658
600
field1: String
@@ -678,23 +620,15 @@ def should_detect_all_breaking_changes():
678
620
VALUE2
679
621
}
680
622
681
- interface Interface1 {
682
- field1: String
683
- }
623
+ interface Interface1
624
+ type TypeThatLoosesInterface1
684
625
685
- type TypeInUnion1 {
686
- field1: String
687
- }
626
+ type TypeInUnion1
627
+ type TypeInUnion2
688
628
689
629
union UnionTypeThatLosesAType = TypeInUnion1
690
630
691
- interface TypeThatChangesType {
692
- field1: String
693
- }
694
-
695
- type TypeThatGainsInterface1 {
696
- field1: String
697
- }
631
+ interface TypeThatChangesType
698
632
699
633
interface TypeThatHasBreakingFieldChanges {
700
634
field2: Boolean
@@ -704,7 +638,6 @@ def should_detect_all_breaking_changes():
704
638
705
639
assert find_breaking_changes (old_schema , new_schema ) == [
706
640
(BreakingChangeType .TYPE_REMOVED , "Int was removed." ),
707
- (BreakingChangeType .TYPE_REMOVED , "TypeInUnion2 was removed." ),
708
641
(BreakingChangeType .TYPE_REMOVED , "TypeThatGetsRemoved was removed." ),
709
642
(
710
643
BreakingChangeType .TYPE_CHANGED_KIND ,
@@ -734,7 +667,7 @@ def should_detect_all_breaking_changes():
734
667
),
735
668
(
736
669
BreakingChangeType .INTERFACE_REMOVED_FROM_OBJECT ,
737
- "TypeThatGainsInterface1 no longer implements interface Interface1." ,
670
+ "TypeThatLoosesInterface1 no longer implements interface Interface1." ,
738
671
),
739
672
(
740
673
BreakingChangeType .DIRECTIVE_REMOVED ,
@@ -906,21 +839,15 @@ def should_detect_if_a_value_was_added_to_an_enum_type():
906
839
def should_detect_interfaces_added_to_types ():
907
840
old_schema = build_schema (
908
841
"""
909
- type Type1 {
910
- field1: String
911
- }
842
+ type Type1
912
843
"""
913
844
)
914
845
915
846
new_schema = build_schema (
916
847
"""
917
- interface Interface1 {
918
- field1: String
919
- }
848
+ interface Interface1
920
849
921
- type Type1 implements Interface1 {
922
- field1: String
923
- }
850
+ type Type1 implements Interface1
924
851
"""
925
852
)
926
853
@@ -934,23 +861,17 @@ def should_detect_interfaces_added_to_types():
934
861
def should_detect_if_a_type_was_added_to_a_union_type ():
935
862
old_schema = build_schema (
936
863
"""
937
- type Type1 {
938
- field1: String
939
- }
864
+ type Type1
865
+ type Type2
940
866
941
867
union UnionType1 = Type1
942
868
"""
943
869
)
944
870
945
871
new_schema = build_schema (
946
872
"""
947
- type Type1 {
948
- field1: String
949
- }
950
-
951
- type Type2 {
952
- field1: String
953
- }
873
+ type Type1
874
+ type Type2
954
875
955
876
union UnionType1 = Type1 | Type2
956
877
"""
@@ -997,17 +918,13 @@ def should_find_all_dangerous_changes():
997
918
}
998
919
999
920
type Type1 {
1000
- field1(name : String = "test"): String
921
+ field1(argThatChangesDefaultValue : String = "test"): String
1001
922
}
1002
923
1003
- type TypeThatGainsInterface1 {
1004
- field1: String
1005
- }
1006
-
1007
- type TypeInUnion1 {
1008
- field1: String
1009
- }
924
+ interface Interface1
925
+ type TypeThatGainsInterface1
1010
926
927
+ type TypeInUnion1
1011
928
union UnionTypeThatGainsAType = TypeInUnion1
1012
929
"""
1013
930
)
@@ -1020,34 +937,23 @@ def should_find_all_dangerous_changes():
1020
937
VALUE2
1021
938
}
1022
939
1023
- interface Interface1 {
1024
- field1: String
1025
- }
1026
-
1027
- type TypeThatGainsInterface1 implements Interface1 {
1028
- field1: String
1029
- }
1030
-
1031
940
type Type1 {
1032
- field1(name : String = "Test"): String
941
+ field1(argThatChangesDefaultValue : String = "Test"): String
1033
942
}
1034
943
1035
- type TypeInUnion1 {
1036
- field1: String
1037
- }
1038
-
1039
- type TypeInUnion2 {
1040
- field1: String
1041
- }
944
+ interface Interface1
945
+ type TypeThatGainsInterface1 implements Interface1
1042
946
947
+ type TypeInUnion1
948
+ type TypeInUnion2
1043
949
union UnionTypeThatGainsAType = TypeInUnion1 | TypeInUnion2
1044
950
"""
1045
951
)
1046
952
1047
953
assert find_dangerous_changes (old_schema , new_schema ) == [
1048
954
(
1049
955
DangerousChangeType .ARG_DEFAULT_VALUE_CHANGE ,
1050
- "Type1.field1 arg name has changed defaultValue" ,
956
+ "Type1.field1 arg argThatChangesDefaultValue has changed defaultValue" ,
1051
957
),
1052
958
(
1053
959
DangerousChangeType .VALUE_ADDED_TO_ENUM ,
0 commit comments