apollographql / apollographql/apollo-tooling

Apollo codegen doesn't return non-zero exit code when errors have been found

Open
#1,980 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

**Intended outcome:**
Running `apollo client:codegen ...` should exit with a number different than 0, when there are errors.

**Actual outcome:**
Running `apollo client:codegen ...` exits by returning 0, even when there are errors. Such as **Error: ️️There are multiple definitions for the AccountSelectorInputQuery operation. All operations in a project must have unique names. If generating types, only the types for the first definition found will be generated.**. This turns out to be problematic on a pipeline where the next command shouldn't be executed, if there are errors on the previous one.

**How to reproduce the issue:**
Create two queries with the same name and run the `apollo client:codegen ...` command. Then run `echo $?` to get its return value. It is 0 but should be different, since there was an error.

**Versions**
2.21.3

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with two queries sharing the same operation name, then run `apollo client:codegen ...` and inspect the `echo $?` result. Trace the `apollo client:codegen` command's error handling and verify that duplicate-definition errors produce a non-zero exit code so subsequent pipeline commands can stop.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.