Skip to content

Feature Request: Add ability to validate types are correct #833

@justinanastos

Description

@justinanastos

I'd like the ability to validate my codegen'ed types from the CLI for two reasons:

  1. CI!

  2. 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.

  2. [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  \
        -
    

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