Skip to content

Commit cb8d351

Browse files
committed
find_breaking_changes: add check for removing repeatable from directive
Replicates graphql/graphql-js@69c4a09
1 parent 6fb9058 commit cb8d351

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/graphql/utilities/find_breaking_changes.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class BreakingChangeType(Enum):
5656
DIRECTIVE_REMOVED = 50
5757
DIRECTIVE_ARG_REMOVED = 51
5858
REQUIRED_DIRECTIVE_ARG_ADDED = 52
59-
DIRECTIVE_LOCATION_REMOVED = 53
59+
DIRECTIVE_REPEATABLE_REMOVED = 53
60+
DIRECTIVE_LOCATION_REMOVED = 54
6061

6162

6263
class DangerousChangeType(Enum):
@@ -154,6 +155,14 @@ def find_directive_changes(
154155
)
155156
)
156157

158+
if old_directive.is_repeatable and not new_directive.is_repeatable:
159+
schema_changes.append(
160+
BreakingChange(
161+
BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED,
162+
f"Repeatable flag was removed from {old_directive.name}.",
163+
)
164+
)
165+
157166
for location in old_directive.locations:
158167
if location not in new_directive.locations:
159168
schema_changes.append(

tests/utilities/test_find_breaking_changes.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,8 @@ def should_detect_all_breaking_changes():
661661
662662
directive @NonNullDirectiveAdded on FIELD_DEFINITION
663663
664+
directive @DirectiveThatWasRepeatable repeatable on FIELD_DEFINITION
665+
664666
directive @DirectiveName on FIELD_DEFINITION | QUERY
665667
666668
type ArgThatChanges {
@@ -697,6 +699,8 @@ def should_detect_all_breaking_changes():
697699
698700
directive @NonNullDirectiveAdded(arg1: Boolean!) on FIELD_DEFINITION
699701
702+
directive @DirectiveThatWasRepeatable on FIELD_DEFINITION
703+
700704
directive @DirectiveName on FIELD_DEFINITION
701705
702706
type ArgThatChanges {
@@ -773,6 +777,10 @@ def should_detect_all_breaking_changes():
773777
BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED,
774778
"A required arg arg1 on directive NonNullDirectiveAdded was added.",
775779
),
780+
(
781+
BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED,
782+
"Repeatable flag was removed from DirectiveThatWasRepeatable.",
783+
),
776784
(
777785
BreakingChangeType.DIRECTIVE_LOCATION_REMOVED,
778786
"QUERY was removed from DirectiveName.",
@@ -858,6 +866,26 @@ def should_detect_if_an_optional_directive_argument_was_added():
858866
)
859867
]
860868

869+
def should_detect_removal_of_repeatable_flag():
870+
old_schema = build_schema(
871+
"""
872+
directive @DirectiveName repeatable on OBJECT
873+
"""
874+
)
875+
876+
new_schema = build_schema(
877+
"""
878+
directive @DirectiveName on OBJECT
879+
"""
880+
)
881+
882+
assert find_breaking_changes(old_schema, new_schema) == [
883+
(
884+
BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED,
885+
"Repeatable flag was removed from DirectiveName.",
886+
)
887+
]
888+
861889
def should_detect_locations_removed_from_a_directive():
862890
old_schema = build_schema(
863891
"""

0 commit comments

Comments
 (0)