TypeGraphQL is a framework for building GraphQL APIs with TypeScript using classes and decorators. Current stable version is v2.0.0-rc.3, actively maintained with regular releases. It leverages TypeScript's decorators and type metadata to define GraphQL types, inputs, and resolvers, reducing boilerplate. Key differentiators include first-class integration with class-validator for input validation and graphql-scalars for custom scalar support. It supports both code-first and schema-first approaches, though decorator-based code-first is preferred. Requires GraphQL v16+, class-validator >=0.14.3, and graphql-scalars >=1.25.0. Beta releases occur every few months.
npm install type-graphqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows defining a GraphQL type with ObjectType and a resolver with Query, then building the schema and starting an Apollo server.
Migrate import statements to ESM syntax and ensure package.json includes 'type': 'module'.
Upgrade Node.js to at least version 20.11.1.
Add import 'reflect-metadata' at the top of your main file.
Replace calls to buildTypeDefsAndResolvers with buildSchema.
Ensure all GraphQL-exposed properties have the @Field decorator.
Always decorate resolver methods appropriately.
Add @Field on each subclass property that should appear in the schema.
Add 'import "reflect-metadata"' at the top of your entry file.
Enable 'emitDecoratorMetadata' and 'experimentalDecorators' in tsconfig.json.
Use @Arg() decorator with explicit type, e.g., @Arg('data', () => RecipeInput) data: RecipeInput.Ensure each class uses only one @ObjectType() (or @InputType, etc.) decorator.