Skip to content

Commit 0eab310

Browse files
authored
Fix thrown errors breaking out of --watch mode (#1627)
1 parent c978df7 commit 0eab310

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

packages/apollo-language-server/src/errors/validation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
ExecutionContext
2929
} from "graphql/execution/execute";
3030
import { hasClientDirective, simpleCollectFields } from "../utilities/graphql";
31+
import { Debug } from "../utilities";
3132

3233
export interface CodeActionInfo {
3334
message: string;
@@ -72,7 +73,7 @@ export function validateQueryDocument(
7273
for (const error of validationErrors) {
7374
logError(error);
7475
}
75-
throw new ToolError("Validation of GraphQL query document failed");
76+
return Debug.error("Validation of GraphQL query document failed");
7677
}
7778
} catch (e) {
7879
console.error(e);

packages/apollo/src/Command.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,7 @@ export abstract class ProjectCommand extends Command {
108108
Debug.SetLoggers({
109109
info: this.log,
110110
warning: this.warn,
111-
error: message => {
112-
this.error(message);
113-
this.exit(1);
114-
}
111+
error: console.error
115112
});
116113

117114
const config = await this.createConfig(flags);

packages/apollo/src/commands/client/codegen.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { Kind, DocumentNode } from "graphql";
55
import tty from "tty";
66
import { Gaze } from "gaze";
77
import URI from "vscode-uri";
8+
import chalk from "chalk";
9+
import { Debug } from "apollo-language-server";
810

911
import { TargetType, default as generate } from "../../generate";
10-
1112
import { ClientCommand } from "../../Command";
1213

1314
const waitForKey = async () => {
@@ -246,7 +247,12 @@ export default class Generate extends ClientCommand {
246247
if (file.indexOf(output) > -1) return;
247248
this.project.fileDidChange(URI.file(file).toString());
248249
console.log("\nChange detected, generating types...");
249-
write();
250+
try {
251+
const fileCount = write();
252+
console.log(`${chalk.green("✔")} Wrote ${fileCount} files`);
253+
} catch (e) {
254+
Debug.error("Error while generating types: " + e.message);
255+
}
250256
});
251257
if (tty.isatty((process.stdin as any).fd)) {
252258
await waitForKey();

0 commit comments

Comments
 (0)