Skip to content

apollo codegen:generate simply ignores malformed queries #1567

@romandecker

Description

@romandecker

When running apollo codegen:generate, and there are some graphql-queries that contain syntax errors, the cli simply ignores the malformed query without any notice.

Intended outcome:

I would expect a warning about malformed queries, or even the whole operation to fail.

Actual outcome:

The apollo-clil just ignores the query and successfully generates code for all other queries it finds:

$ apollo codegen:generate --localSchemaFile src/common/__generated__/schema.json --globalTypesFile src/common/__generated__/globalSchemaTypes.ts --target typescript
  ✔ Loading Apollo Project
  ✔ Generating query files with 'typescript' target - wrote 10 files

How to reproduce the issue:

I forked the apollo-tutorial repo to showcase the issue:

  1. git clone https://github.com/DeX3/fullstack-tutorial
  2. Go to the client directory:
$ cd final/client
  1. Install dependencies:
$ yarn # or npm install
  1. Run apollo codegen:generate:
 $ npx apollo codegen:generate --target flow --includes src/sample-queries.js --localSchemaFile schema.json
  ✔ Loading Apollo Project
  ✔ Generating query files with 'flow' target - wrote 1 files

There are two queries defined in src/sample-queries.js, a valid one (which is correctly picked up by apollo-cli) and one with a syntax error, which is silently ignored - which might be a problem.

Versions

  • apollo/2.19.0
  • OS: darwin-x64
  • Node: node-v12.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions