Skip to content

apvilkko/graphql-codegen-demo

Repository files navigation

GraphQL Code Generator With TypeScript Demo

Using GraphQL Code Generator to generate types and client code against an existing GraphQL backend.

The problem

  • Backend server is not directly usable in client code, because (choose any that apply)
    • it is external, maintained by another team/organisation
    • it is in a separate repo
    • it is written in another language
  • Maintaining typings in multiple codebases violates DRY
    • when backend changes client breaks without indication

The solution

  • Generate typings and client code automatically against a backend server
  • Type checking can be used to break the client build/CI/tests when backend schema changes

Development

Setup

yarn ; yarn lerna bootstrap ; yarn build

Start client at http://localhost:4000

yarn start

Update typings (while server running):

yarn codegen

Check for type errors (you'd run this in CI with tests):

yarn type-check

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published