Type GraphQL Query Overview
Type GraphQL Query is a powerful library that allows you to build GraphQL APIs using TypeScript classes and decorators. It automatically generates GraphQL schemas, resolvers, queries, mutations, and subscriptions from your TypeScript code.
What You’ll Learn
Section intitulée « What You’ll Learn »This documentation will help you understand:
- ✅ How to define GraphQL types using TypeScript classes
- ✅ How to create queries, mutations, and subscriptions
- ✅ How to implement filtering, sorting, and paging
- ✅ How to manage relationships between entities
- ✅ How to implement authorization and access control
- ✅ How to use advanced features like aggregations, search, and translations
Key Features
Section intitulée « Key Features »Type GraphQL Query provides a comprehensive set of features for building GraphQL APIs:
| Feature | Description |
|---|---|
| 🎯 Type Safety | Full TypeScript support with compile-time type checking |
| 🎨 Decorators | Use decorators to define GraphQL types and fields |
| ⚡ Code Generation | Automatic GraphQL schema and resolver generation |
| ✅ Validation | Built-in validation support for inputs |
| 🔍 Filtering | Powerful filtering system with complex conditions |
| 📊 Sorting & Paging | Built-in sorting and paging support |
| 🔗 Relations | Easy relationship management between entities |
| 🔐 Authorization | Built-in authorization and access control |
| 🔄 Subscriptions | Real-time updates with GraphQL subscriptions |
| 🌍 Translations | Multi-language support for fields |
| 🔎 Search | Full-text search capabilities |
| 📈 Aggregations | Aggregate queries for analytics |
Core Concepts
Section intitulée « Core Concepts »DTOs (Data Transfer Objects)
Section intitulée « DTOs (Data Transfer Objects) »Define your GraphQL types using TypeScript classes with decorators:
import { ObjectType, ID } from '@lib/type-graphql';import { EnhancedField, IDField } from '@lib/type-graphql-query';
@ObjectType()export class Product { @IDField(() => ID) id: string;
@EnhancedField(() => String) name: string;}Automatically generated queries with filtering, sorting, and paging:
query { products( filter: { name: { like: "%laptop%" } } sorting: [{ field: name, direction: ASC }] paging: { limit: 10, offset: 0 } ) { nodes { id name } totalCount }}Mutations
Section intitulée « Mutations »Automatically generated mutations for create, update, delete, and upsert operations:
mutation { createOneProduct(input: { name: "New Product" }) { id name }}Relations
Section intitulée « Relations »Define relationships between entities:
@Relation('category', () => Category)category: Category;Quick Start
Section intitulée « Quick Start »Ready to get started? Follow these steps:
- 📖 Getting Started - Set up and create your first DTO
- 📝 DTOs - Learn how to define data transfer objects
- 🔍 Queries - Understand query operations
- ✏️ Mutations - Learn about mutations
Documentation Structure
Section intitulée « Documentation Structure »Our documentation is organized to help you learn progressively:
Fundamentals
Section intitulée « Fundamentals »- DTOs - Define your data structures
- Types - GraphQL type system
- QueryService - Core service interface
- Assemblers - DTO to Entity translation
GraphQL Operations
Section intitulée « GraphQL Operations »- Resolvers - How resolvers work
- Queries - Query operations with filtering, sorting, paging
- Mutations - Create, update, delete operations
- Subscriptions - Real-time updates
- ListenChanges - Database change notifications
Configuration
Section intitulée « Configuration »- QueryOptions - Configure query behavior
- ContextFilter - Context-aware filtering
Advanced Features
Section intitulée « Advanced Features »- Relations - Entity relationships
- Aggregations - Aggregate queries
- Search - Full-text search
- Translations - Multi-language support
- Soft Delete - Soft delete functionality
Security & Control
Section intitulée « Security & Control »- Authorization - Access control
- Hooks - Lifecycle hooks
Extensions
Section intitulée « Extensions »- DataLoaders - N+1 query optimization
- Federation - GraphQL federation
Next Steps
Section intitulée « Next Steps »Ready to dive in? Start with these essential topics:
- 🚀 Getting Started - Quick start guide
- 📝 DTOs - Learn how to define types
- 🔍 Queries - Understand query operations
- ✏️ Mutations - Learn about mutations
Related Topics
Section intitulée « Related Topics »- API Overview - Understand the API architecture
- Code Structure - Learn about module organization
- Development Guide - Development workflow