apollographql / apollographql/apollo-tooling
Feature Request: Add ability to validate types are correct
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
I'd like the ability to validate my codegen'ed types from the CLI for two reasons:
1. CI!
1. When I forget to update types on the fly, I'd like to be able to use something like `git bisect` to find exactly which commit I forgot to update the types in:
```
git bisect run npx apollo client:codegen \
--config=[config-filename] \
--passthroughCustomScalars \
--outputFlat \
--validate
```
I can think of two ways to handle this:
1. [Preferred] Add an option that generates types, compares to all files that will be written instead of actually writing, and then exit with a non-zero exit code if any files are incorrect.
1. [Stopgap?] Allow output to stdout instead of always writing to a file
For example, allow a `-` param to signify that we want to write to `stdout` instead of a real file; possibly only allow such an option when `--outputFlat` is also specified.
```
npx apollo client:codegen --config=[config-filename] \
--passthroughCustomScalars \
--outputFlat \
--target=typescript \
-
```
Contributor guide
Research direction
Start with the `apollo client:codegen` CLI entry point and review how `--config`, `--outputFlat`, `--target`, and scalar options select generated files. Define the validation behavior around comparing generated output without writing it and returning a non-zero exit code when files differ. Confirm completion with a CI-style command and the existing codegen checks, if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100