Skip to content

Commit

Permalink
Fix silent codegen errors on syntax errors (#1899)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeDawkins authored Jun 3, 2020
1 parent abedfb2 commit ea1e0f4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/apollo/src/commands/client/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ export default class Generate extends ClientCommand {
// are valid documents
project.validate();

// to prevent silent erroring of syntax errors, we check the project's
// documents to make sure there are no errors. If there are, we error here
// instead of project initialization
for (const document of this.project.documents) {
if (document.syntaxErrors.length) {
const errors = document.syntaxErrors.map(
e =>
`Syntax error in ${document.source.name}: ${e.message}\n`
);
throw new Error(errors.toString());
}
}

const operations = Object.values(this.project.operations);
const fragments = Object.values(this.project.fragments);

Expand Down

0 comments on commit ea1e0f4

Please sign in to comment.