# michallytek/type-graphql

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/michallytek-type-graphql).**

8,088 stars · 671 forks · TypeScript · MIT

## Links

- GitHub: https://github.com/MichalLytek/type-graphql
- Homepage: https://typegraphql.com
- awesome-repositories: https://awesome-repositories.com/repository/michallytek-type-graphql.md

## Description

Type-graphql is a toolkit and framework for creating type-safe GraphQL APIs. It functions as a schema generator and resolver library that uses TypeScript classes and decorators as the primary source of truth for data structures and query logic.

The project enables the definition of GraphQL schemas and resolvers through typed classes rather than manual schema definition language. This approach ensures that TypeScript types automatically align with the GraphQL schema to prevent runtime errors.

The framework provides capabilities for API implementation, including input data validation and access control through guards. It further supports resolver organization via dependency injection and controller classes.

## Tags

### Web Development

- [GraphQL APIs](https://awesome-repositories.com/f/web-development/graphql-apis.md) — Provides a framework for exposing data models through automatically generated type-safe GraphQL interfaces.
- [GraphQL Schema Generation](https://awesome-repositories.com/f/web-development/graphql-schema-generation.md) — Provides a framework to generate GraphQL schemas and resolvers using TypeScript classes and decorators as the source of truth.
- [Field Resolvers](https://awesome-repositories.com/f/web-development/graphql-apis/field-resolvers.md) — Implements field resolvers within controller classes to handle data fetching and mutations. ([source](https://github.com/michallytek/type-graphql#readme))
- [GraphQL Schema Definitions](https://awesome-repositories.com/f/web-development/graphql-schema-definitions.md) — Defines GraphQL schemas and types using TypeScript classes to maintain a single source of truth.
- [Schema-First Development Frameworks](https://awesome-repositories.com/f/web-development/graphql-schema-generation/schema-first-development-frameworks.md) — Prioritizes typed classes as the source of truth for generating the GraphQL schema and logic.
- [Type-Safe API Frameworks](https://awesome-repositories.com/f/web-development/type-safe-api-frameworks.md) — Leverages the TypeScript static type system to ensure the GraphQL schema and API contracts align.
- [Controller-Based Organization](https://awesome-repositories.com/f/web-development/data-fetching-caching/data-fetching/resolver-based-fetching/controller-based-organization.md) — Structures business logic and data fetching using class-based controllers and dependency injection.

### Part of an Awesome List

- [GraphQL](https://awesome-repositories.com/f/awesome-lists/devtools/graphql.md) — Provides a library for implementing GraphQL queries and mutations via typed controller classes.
- [Web Frameworks](https://awesome-repositories.com/f/awesome-lists/devtools/web-frameworks.md) — Framework for creating GraphQL APIs using TypeScript classes and decorators.

### Software Engineering & Architecture

- [Schema Generation](https://awesome-repositories.com/f/software-engineering-architecture/decorator-patterns/decorators/schema-generation.md) — Uses class decorators to automatically derive GraphQL schemas from TypeScript metadata at runtime.
- [Single-Source-of-Truth Modeling](https://awesome-repositories.com/f/software-engineering-architecture/single-source-of-truth-modeling.md) — Uses TypeScript classes as the shared primary definition for both data models and the GraphQL schema.
- [Dependency Injection Containers](https://awesome-repositories.com/f/software-engineering-architecture/dependency-injection-containers.md) — Provides an inversion-of-control container to decouple business logic from GraphQL resolvers.
- [Dependency Injection](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/dependency-injection.md) — Decouples business logic from the API by injecting required service dependencies into resolvers. ([source](https://github.com/michallytek/type-graphql#readme))
- [Metadata Reflection Frameworks](https://awesome-repositories.com/f/software-engineering-architecture/metadata-reflection-frameworks.md) — Utilizes reflect-metadata to dynamically inspect decorated class properties for schema generation.
- [Request Interception Middleware](https://awesome-repositories.com/f/software-engineering-architecture/request-interception-middleware.md) — Implements a chain of guards and validation functions that intercept requests before they reach resolvers.

### Programming Languages & Runtimes

- [Resolver Mappings](https://awesome-repositories.com/f/programming-languages-runtimes/class-based-architecture/class-based-schema-mapping/resolver-mappings.md) — Maps GraphQL queries and mutations to specific methods within controller classes using metadata reflection.

### Security & Cryptography

- [Access Control Guards](https://awesome-repositories.com/f/security-cryptography/access-control-guards.md) — Uses guards to block unauthorized requests to specific GraphQL resolvers based on security policies. ([source](https://github.com/michallytek/type-graphql#readme))
- [Input Validation](https://awesome-repositories.com/f/security-cryptography/input-validation.md) — Verifies and sanitizes incoming GraphQL arguments against defined rules to ensure data integrity. ([source](https://github.com/michallytek/type-graphql#readme))
