Generate TypeScript Types From a GraphQL Schema

InstructorTomasz Łakomy

Share this video with your friends

Send Tweet

It would quickly get out of hand if we had to create TypeScript types for every type in our GraphQL schema. Luckily there are a couple packages from graphql-codegen that we can use to make our lives easier.

We'll create a codegen.yml file where we'll specify our GraphQL schema and choose the location of the types file we want to generate based on the schema.

Then we can create a script in our package.json that runs the codegen.

For more on using TypeScript with AppSync Lambda Resolvers, check out Benoît Bouré blog post: How to use TypeScript with AppSync Lambda Resolvers