Skip to content

Binary that lets you add guard functions for Apollo generated types

Notifications You must be signed in to change notification settings

ChibiBlasphem/apollo-type-guards

Repository files navigation

Apollo Type Guards

This binary lets you enhance types generated by Apollo CLI by creating type guards associated with it.

Install

With npm:

npm install --save-dev apollo-type-guards

With yarn:

yarn add --dev apollo-type-guards

Usage

  • Run apollo client:codegen CLI to generate types files from your schema
  • Run
    apollo-type-guards --globDir="glob/to/generated/folders"
    
  • Depending on you folder structure you should see something like this:
    Before :
    .
    └── src
        └── __generated__
            ├── QueryOne.ts
            └── QueryTwo.ts
    
    After:
    .
    └── src
        └── __generated__
            ├── guards
            │   ├── QueryOne.ts
            │   └── QueryTwo.ts
            ├── QueryOne.ts
            └── QueryTwo.ts
    

About

Binary that lets you add guard functions for Apollo generated types

Resources

Stars

Watchers

Forks

Packages

No packages published