Aller au contenu

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.

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

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

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
}
}

Automatically generated mutations for create, update, delete, and upsert operations:

mutation {
createOneProduct(input: { name: "New Product" }) {
id
name
}
}

Define relationships between entities:

@Relation('category', () => Category)
category: Category;

Ready to get started? Follow these steps:

  1. 📖 Getting Started - Set up and create your first DTO
  2. 📝 DTOs - Learn how to define data transfer objects
  3. 🔍 Queries - Understand query operations
  4. ✏️ Mutations - Learn about mutations

Our documentation is organized to help you learn progressively:

Ready to dive in? Start with these essential topics:

  1. 🚀 Getting Started - Quick start guide
  2. 📝 DTOs - Learn how to define types
  3. 🔍 Queries - Understand query operations
  4. ✏️ Mutations - Learn about mutations