We all know that GraphQL is so great and solves many problems that we have with REST API, like overfetching and underfetching. But developing a GraphQL API in Node.js with TypeScript is sometimes a bit of pain.
The biggest problem is the types definition redundancy in our codebase, which makes it difficult to keep things in sync. To add a new field to our entity, we have to jump through all the files - modify an entity class, the schema, and regenerate the schema types. It's easy to forget to update one piece or make a mistake with a single type.
TypeGraphQL comes to address this issues, based on experience from a few years of developing GraphQL APIs in TypeScript. The main idea is to have only one source of truth by defining the schema using classes and a bit of decorators help. Additional features like dependency injection, validation or auth guards helps with common tasks that normally we would have to handle by ourselves.
Define your whole schema, including types, interfaces, enums, unions and subscriptions
Create the schema, types and resolvers only with TypeScript, using classes and decorators!
🔨 Advanced features
Use features like automatic validation, authorization guards, middlewares, dependency injection and plenty more...