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 display of unformatted errors in composition #1806

Merged
merged 3 commits into from
Feb 21, 2020
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
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