Skip to main content

Overview

The QueryManager class provides comprehensive CRUD operations with advanced features like optimistic updates and automatic cache management. It internally uses two important classes: QueryKeys for managing React Query keys and cache operations, and Mutations for handling cache mutations and optimistic updates.

Architecture Overview

QueryManager
├── QueryKeys - Manages query keys and cache operations
├── Mutations - Handles cache mutations and optimistic updates
└── Hooks - Provides React hooks for CRUD operations

Core Concepts

QueryItem

All data items must extend the QueryItem interface:

interface QueryItem {
id: string | number
}

// Example implementation
interface User extends QueryItem {
id: string
name: string
email: string
status: 'active' | 'inactive'
createdAt: string
}

Filter Types

Define filter interfaces for list queries:

interface UserFilters {
status?: 'active' | 'inactive'
search?: string
role?: string
}