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: do not make "Field is missing" suppressable on type level #338

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/model/compatibility-check/check-key-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export function checkKeyField(
// special case: If the baseline requires id: ID @key, the fieldToCheck might not be authored at all
// (because it's an automatic system field). We need to tell the user that the field needs to be added.
if (fieldToCheck.isSystemField && fieldToCheck.name === ID_FIELD && !fieldToCheck.astNode) {
// we currently can't suppress missing fields in general. Rather than adding a special
// code for "id", wait until we have a way to suppress missing fields in general.
context.addMessage(
ValidationMessage.suppressableCompatibilityIssue(
'MISSING_FIELD',
ValidationMessage.nonSuppressableCompatibilityIssue(
`Field "id: ID @key" needs to be specified${getRequiredBySuffix(
baselineField,
)}.`,
fieldToCheck.declaringType.astNode,
{ location: fieldToCheck.declaringType.nameASTNode },
fieldToCheck.declaringType.nameASTNode ?? fieldToCheck.declaringType.astNode,
),
);
} else {
Expand Down
9 changes: 5 additions & 4 deletions src/model/compatibility-check/check-object-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ export function checkObjectType(
);
}

// cannot easily make this suppressable - if we would accept a @suppress on the type,
// that would supress all missing fields, not just this one
context.addMessage(
ValidationMessage.suppressableCompatibilityIssue(
'MISSING_FIELD',
ValidationMessage.nonSuppressableCompatibilityIssue(
`Field "${baselineType.name}.${
baselineField.name
}" is missing${getRequiredBySuffix(baselineField)}.`,
typeToCheck.astNode,
{ location: typeToCheck.nameASTNode, quickFixes },
typeToCheck.nameASTNode ?? typeToCheck.astNode,
{ quickFixes },
),
);
continue;
Expand Down
1 change: 0 additions & 1 deletion src/model/validation/suppress/message-codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export const COMPATIBILITY_ISSUE_CODES = {
DEFAULT_VALUE: 'Missing, superfluous or diverging @defaultValue',
MISSING_ENUM_VALUE: 'An enum declaration is missing a value',
FIELD_TYPE: 'A field has the wrong type',
MISSING_FIELD: 'An object type declaration is missing a field',
KEY_FIELD: 'Missing or superfluous @key',
REFERENCE: 'Missing, superfluous or diverging @reference',
RELATION: 'Missing, superfluous or diverging @relation',
Expand Down
Loading