Skip to content

Commit

Permalink
Fix display of unformatted errors in composition (#1806)
Browse files Browse the repository at this point in the history
* Fix display of unformatted errors in composition

* Update changelog

* update types
  • Loading branch information
JakeDawkins committed Feb 21, 2020
1 parent 4953e0f commit 5f8c98b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

- `apollo`
- Update shortlinks to use go.apollo.dev instead of bitly [#1790](https://github.com/apollographql/apollo-tooling/pull/1790)
- Support disabling literal stripping when extracting queries. [1703](https://github.com/apollographql/apollo-tooling/pull/1703)
- Support disabling literal stripping when extracting queries. [1703](https://github.com/apollographql/apollo-tooling/pull/1703)
- Fix rendering of unexpected composition errors throwing a table cell error [#1806](https://github.com/apollographql/apollo-tooling/pull/1806)
- `apollo-codegen-flow`
- Add @generated comment
- `apollo-codegen-scala`
Expand Down
9 changes: 9 additions & 0 deletions packages/apollo-language-server/src/graphqlTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ export interface ListServices_service {
}

export interface ListServices {
/**
* Service by ID
*/
service: ListServices_service | null;
}

Expand Down Expand Up @@ -537,6 +540,9 @@ export interface SchemaTagsAndFieldStats_service {
}

export interface SchemaTagsAndFieldStats {
/**
* Service by ID
*/
service: SchemaTagsAndFieldStats_service | null;
}

Expand Down Expand Up @@ -1148,6 +1154,9 @@ export interface GetSchemaByTag_service {
}

export interface GetSchemaByTag {
/**
* Service by ID
*/
service: GetSchemaByTag_service | null;
}

Expand Down
45 changes: 31 additions & 14 deletions packages/apollo/src/commands/service/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ export default class ServiceCheck extends ProjectCommand {
const decodedErrors = compositionValidationResult.errors
.filter(isNotNullOrUndefined)
.map(error => {
// checks for format: [serviceName] Location -> Error Message
const match = error.message.match(
/^\[([^\[]+)\]\s+(\S+)\ ->\ (.+)/
);
Expand Down Expand Up @@ -639,22 +640,38 @@ export default class ServiceCheck extends ProjectCommand {
// Add a cosmetic line break
console.log("");

this.log(
table(
[
["Service", "Field", "Message"],
...compositionErrors.map(Object.values)
],
{
columns: {
2: {
width: 50,
wrapWord: true
// errors that DONT match the expected format: [service] field -> message
const unformattedErrors = compositionErrors.filter(
e => !e.field && !e.service
);
// errors that match the expected format: [service] field -> message
const formattedErrors = compositionErrors.filter(
e => e.field || e.service
);

if (formattedErrors.length)
this.log(
table(
[
["Service", "Field", "Message"],
...formattedErrors.map(Object.values)
],
{
columns: {
2: {
width: 50,
wrapWord: true
}
}
}
}
)
);
)
);

// list out errors which we couldn't determine Service name and/or location names
if (unformattedErrors.length)
this.log(
table([["Message"], ...unformattedErrors.map(e => [e.message])])
);

// Return a non-zero error code
this.exit(1);
Expand Down

0 comments on commit 5f8c98b

Please sign in to comment.