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

apollo codegen:generate simply ignores malformed queries #1567

Open
romandecker opened this issue Oct 7, 2019 · 4 comments
Open

apollo codegen:generate simply ignores malformed queries #1567

romandecker opened this issue Oct 7, 2019 · 4 comments
Labels
🤖 component - codegen related to the codegen core packages

Comments

@romandecker
Copy link

romandecker commented Oct 7, 2019

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
@JakeDawkins JakeDawkins added the 🤖 component - codegen related to the codegen core packages label Oct 11, 2019
@satshabad-cr
Copy link

Any work around? This has bit me too!

@damacisaac
Copy link

I was also expecting it to fail completely. If that were the case we could also use it in our test suite to ensure all of our queries are well formed.

@mikyoengine
Copy link

This is biting us as well. is this because gql-tag is not exposing a parsing error?

@apieceofbart
Copy link

It's the same as #1897 and I believe there's a PR fixing: #1899

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 component - codegen related to the codegen core packages
Projects
None yet
Development

No branches or pull requests

6 participants