Skip to content

Commit

Permalink
findBreakingChanges: add check for removing repeatable from directive
Browse files Browse the repository at this point in the history
Code is taken from graphql#1541
  • Loading branch information
IvanGoncharov committed Jan 30, 2020
1 parent 82c2eea commit 0ad4c06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/utilities/findBreakingChanges.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type _BreakingChangeType = {
DIRECTIVE_REMOVED: 'DIRECTIVE_REMOVED';
DIRECTIVE_ARG_REMOVED: 'DIRECTIVE_ARG_REMOVED';
REQUIRED_DIRECTIVE_ARG_ADDED: 'REQUIRED_DIRECTIVE_ARG_ADDED';
DIRECTIVE_REPEATABLE_REMOVED: 'DIRECTIVE_REPEATABLE_REMOVED',
DIRECTIVE_LOCATION_REMOVED: 'DIRECTIVE_LOCATION_REMOVED';
};

Expand Down
8 changes: 8 additions & 0 deletions src/utilities/findBreakingChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const BreakingChangeType = Object.freeze({
DIRECTIVE_REMOVED: 'DIRECTIVE_REMOVED',
DIRECTIVE_ARG_REMOVED: 'DIRECTIVE_ARG_REMOVED',
REQUIRED_DIRECTIVE_ARG_ADDED: 'REQUIRED_DIRECTIVE_ARG_ADDED',
DIRECTIVE_REPEATABLE_REMOVED: 'DIRECTIVE_REPEATABLE_REMOVED',
DIRECTIVE_LOCATION_REMOVED: 'DIRECTIVE_LOCATION_REMOVED',
});

Expand Down Expand Up @@ -148,6 +149,13 @@ function findDirectiveChanges(
});
}

if (oldDirective.isRepeatable && !newDirective.isRepeatable) {
schemaChanges.push({
type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED,
description: `Repeatable flag was removed from ${oldDirective.name}.`,
});
}

for (const location of oldDirective.locations) {
if (newDirective.locations.indexOf(location) === -1) {
schemaChanges.push({
Expand Down

0 comments on commit 0ad4c06

Please sign in to comment.