Skip to content
Open
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
18 changes: 18 additions & 0 deletions packages/commands/validate/__tests__/validate-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const schema = buildSchema(/* GraphQL */ `
title: String
createdAt: String
modifiedAt: String
deprecatedTitle: String @deprecated(reason: "Will be deleted")
}

type Query {
Expand Down Expand Up @@ -60,6 +61,16 @@ const validate = createCommand({
`),
location: 'valid-document.graphql',
},
{
document: parse(/* GraphQL */ `
query post {
post {
deprecatedTitle
}
}
`),
location: 'with-deprecated-only.graphql',
},
];
},
},
Expand Down Expand Up @@ -116,4 +127,11 @@ describe('validate', () => {

expect(spyReporter).not.toHaveBeenCalledNormalized('document.graphql:');
});

test('should log deprecation when file has only deprecation', async () => {
await mockCommand(validate, 'validate "*.graphql" schema.graphql');

expect(spyReporter).toHaveBeenCalledNormalized('in with-deprecated-only.graphql');
expect(spyReporter).toHaveBeenCalledNormalized('The field Post.deprecatedTitle is deprecated. Will be deleted');
})
});
2 changes: 1 addition & 1 deletion packages/commands/validate/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ function printInvalidDocuments(
}

for (const doc of invalidDocuments) {
if (doc.errors.length) {
if (doc[listKey].length) {
for (const line of renderErrors(doc.source.name, doc[listKey], isError)) {
Logger.log(line);
}
Expand Down