Skip to content

Commit 5f8c98b

Browse files
authored
Fix display of unformatted errors in composition (#1806)
* Fix display of unformatted errors in composition * Update changelog * update types
1 parent 4953e0f commit 5f8c98b

3 files changed

Lines changed: 42 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
- `apollo`
66
- Update shortlinks to use go.apollo.dev instead of bitly [#1790](https://github.com/apollographql/apollo-tooling/pull/1790)
7-
- Support disabling literal stripping when extracting queries. [1703](https://github.com/apollographql/apollo-tooling/pull/1703)
7+
- Support disabling literal stripping when extracting queries. [1703](https://github.com/apollographql/apollo-tooling/pull/1703)
8+
- Fix rendering of unexpected composition errors throwing a table cell error [#1806](https://github.com/apollographql/apollo-tooling/pull/1806)
89
- `apollo-codegen-flow`
910
- Add @generated comment
1011
- `apollo-codegen-scala`

packages/apollo-language-server/src/graphqlTypes.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ export interface ListServices_service {
355355
}
356356

357357
export interface ListServices {
358+
/**
359+
* Service by ID
360+
*/
358361
service: ListServices_service | null;
359362
}
360363

@@ -537,6 +540,9 @@ export interface SchemaTagsAndFieldStats_service {
537540
}
538541

539542
export interface SchemaTagsAndFieldStats {
543+
/**
544+
* Service by ID
545+
*/
540546
service: SchemaTagsAndFieldStats_service | null;
541547
}
542548

@@ -1148,6 +1154,9 @@ export interface GetSchemaByTag_service {
11481154
}
11491155

11501156
export interface GetSchemaByTag {
1157+
/**
1158+
* Service by ID
1159+
*/
11511160
service: GetSchemaByTag_service | null;
11521161
}
11531162

packages/apollo/src/commands/service/check.ts

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ export default class ServiceCheck extends ProjectCommand {
370370
const decodedErrors = compositionValidationResult.errors
371371
.filter(isNotNullOrUndefined)
372372
.map(error => {
373+
// checks for format: [serviceName] Location -> Error Message
373374
const match = error.message.match(
374375
/^\[([^\[]+)\]\s+(\S+)\ ->\ (.+)/
375376
);
@@ -639,22 +640,38 @@ export default class ServiceCheck extends ProjectCommand {
639640
// Add a cosmetic line break
640641
console.log("");
641642

642-
this.log(
643-
table(
644-
[
645-
["Service", "Field", "Message"],
646-
...compositionErrors.map(Object.values)
647-
],
648-
{
649-
columns: {
650-
2: {
651-
width: 50,
652-
wrapWord: true
643+
// errors that DONT match the expected format: [service] field -> message
644+
const unformattedErrors = compositionErrors.filter(
645+
e => !e.field && !e.service
646+
);
647+
// errors that match the expected format: [service] field -> message
648+
const formattedErrors = compositionErrors.filter(
649+
e => e.field || e.service
650+
);
651+
652+
if (formattedErrors.length)
653+
this.log(
654+
table(
655+
[
656+
["Service", "Field", "Message"],
657+
...formattedErrors.map(Object.values)
658+
],
659+
{
660+
columns: {
661+
2: {
662+
width: 50,
663+
wrapWord: true
664+
}
653665
}
654666
}
655-
}
656-
)
657-
);
667+
)
668+
);
669+
670+
// list out errors which we couldn't determine Service name and/or location names
671+
if (unformattedErrors.length)
672+
this.log(
673+
table([["Message"], ...unformattedErrors.map(e => [e.message])])
674+
);
658675

659676
// Return a non-zero error code
660677
this.exit(1);

0 commit comments

Comments
 (0)