Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(BA-449): Allow new version notation in GQL schema #3362

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions gql-inspector-checker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module.exports = (props) => {
const { changes, newSchema, oldSchema } = props;
return changes.map((change) => {
const deprecateNotationRegex = /Deprecated since (\d{2}\.\d{2}.\d{1})/;
const addNotationRegex = /Added in (\d{2}\.\d{2}.\d{1})/;
// Allowed version notations: 'XX.XX.X', 'XX.X.X'
const deprecateNotationRegex = /Deprecated since (\d{2}\.\d{1,2}\.\d{1})/;
const addNotationRegex = /Added in (\d{2}\.\d{1,2}\.\d{1})/;
if (
[
"FIELD_DEPRECATION_REASON_ADDED",
Expand All @@ -15,9 +16,9 @@ module.exports = (props) => {
if (newReason && !newReason.match(deprecateNotationRegex)) {
change.criticality.level = "BREAKING";
change.criticality.reason =
'Deprecation reason must include a version number in the format "Deprecated since XX.XX.X."';
'Deprecation reason must include a version number in the format "Deprecated since XX.XX.X." or "Deprecated since XX.X.X."';
change.message =
'Deprecation reason must include a version number in the format "Deprecated since XX.XX.X.", ' +
'Deprecation reason must include a version number in the format "Deprecated since XX.XX.X." or "Deprecated since XX.X.X.", ' +
change.message;
}
} else if (
Expand All @@ -31,9 +32,9 @@ module.exports = (props) => {
if (!description || (description && !description.match(addNotationRegex))) {
change.criticality.level = "BREAKING";
change.criticality.reason =
'New fields must include a description with a version number in the format "Added in XX.XX.X."';
'New fields must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X."';
change.message =
'New fields must include a description with a version number in the format "Added in XX.XX.X.", ' +
'New fields must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X.", ' +
change.message;
}
} else if (
Expand All @@ -46,9 +47,9 @@ module.exports = (props) => {
if (!description || (description && !description.match(addNotationRegex))) {
change.criticality.level = "BREAKING";
change.criticality.reason =
'New types must include a description with a version number in the format "Added in XX.XX.X."';
'New types must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X."';
change.message =
'New types must include a description with a version number in the format "Added in XX.XX.X.", ' +
'New types must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X.", ' +
change.message;
}
} else if (
Expand All @@ -65,9 +66,9 @@ module.exports = (props) => {
if (!description || (description && !description.match(addNotationRegex))) {
change.criticality.level = "BREAKING";
change.criticality.reason =
'New arguments must include a description with a version number in the format "Added in XX.XX.X."';
'New arguments must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X."';
change.message =
'New arguments must include a description with a version number in the format "Added in XX.XX.X.", ' +
'New arguments must include a description with a version number in the format "Added in XX.XX.X." or "Added in XX.X.X.", ' +
change.message;
} else {
change.criticality.level = "DANGEROUS";
Expand Down
Loading