grpc_graphql_gateway 1.2.5

A Rust implementation of gRPC-GraphQL gateway - generates GraphQL execution code from gRPC services
# Advanced Live Query Features - Visual Overview

```
╔═══════════════════════════════════════════════════════════════════════════════╗
║                    ADVANCED LIVE QUERY FEATURES                               ║
║                    gRPC GraphQL Gateway                                       ║
╚═══════════════════════════════════════════════════════════════════════════════╝

┌───────────────────────────────────────┐  ┌───────────────────────────────────┐
│  1️⃣  FILTERED LIVE QUERIES            │  │  2️⃣  FIELD-LEVEL INVALIDATION    │
│                                       │  │                                   │
│  GraphQL Query:                       │  │  Old Data:                        │
│  ┌─────────────────────────────────┐  │  │  ┌─────────────────────────────┐ │
│  │ query @live {                   │  │  │  │ {                           │ │
│  │   users(status: ONLINE) {       │  │  │  │   user: {                   │ │
│  │     users { id name }           │  │  │  │     id: "1",                │ │
│  │   }                             │  │  │  │     name: "Alice",     ◄────┤─┼─┐
│  │ }                               │  │  │  │     email: "a@ex.com", ───┐ │ │ │
│  └─────────────────────────────────┘  │  │  │     age: 30            ◄──┼─┤─┤─┼─ Changed!
│              ↓                         │  │  │   }                    ───┘ │ │ │
│  Filter: { status: "ONLINE" }         │  │  │ }                           │ │ │
│              ↓                         │  │  └─────────────────────────────┘ │ │
│  ┌─────────────────────────────────┐  │  │                                   │ │
│  │ ✓ User 1 (ONLINE)   ← Include  │  │  │  New Data:                        │ │
│  │ ✗ User 2 (OFFLINE)  ← Filter   │  │  │  ┌─────────────────────────────┐ │ │
│  │ ✓ User 3 (ONLINE)   ← Include  │  │  │  │ {                           │ │ │
│  └─────────────────────────────────┘  │  │  │   user: {                   │ │ │
│                                       │  │  │     id: "1",                │ │ │
│  Result: Only ONLINE users sent       │  │  │     name: "Alice Smith", ◄──┼─┘ │
│  💡 50-90% bandwidth reduction        │  │  │     email: "a@ex.com",      │   │
└───────────────────────────────────────┘  │  │     age: 31              ◄──┼───┘
                                           │  │   }                           │
                                           │  │ }                             │
                                           │  └───────────────────────────────┘
                                           │              ↓
                                           │  changed_fields: ["user.name",   │
                                           │                   "user.age"]    │
                                           │                                   │
                                           │  💡 30-70% bandwidth reduction    │
                                           │  💡 Surgical UI updates           │
                                           └───────────────────────────────────┘

┌───────────────────────────────────────┐  ┌───────────────────────────────────┐
│  3️⃣  BATCH INVALIDATION               │  │  4️⃣  CACHE CONTROL                │
│                                       │  │                                   │
│  Without Batching:                    │  │  Data Volatility → Cache Time:    │
│  ┌─────────────────────────────────┐  │  │                                   │
│  │ Event 1 (0ms)  → Update 1       │  │  │  ┌──────────────────────────┐    │
│  │ Event 2 (10ms) → Update 2       │  │  │  │ VeryHigh  →  0s   (none) │    │
│  │ Event 3 (20ms) → Update 3       │  │  │  │ High      →  5s          │    │
│  │ Event 4 (30ms) → Update 4       │  │  │  │ Medium    →  30s         │    │
│  │ Event 5 (40ms) → Update 5       │  │  │  │ Low       →  5min        │    │
│  └─────────────────────────────────┘  │  │  │ VeryLow   →  1hr         │    │
│           ↓ 5 updates                 │  │  └──────────────────────────┘    │
│                                       │  │              ↓                     │
│  With Batching (100ms debounce):      │  │  Response Headers:                │
│  ┌─────────────────────────────────┐  │  │  ┌──────────────────────────┐    │
│  │ Event 1, 2, 3, 4, 5             │  │  │  │ Cache-Control:           │    │
│  │        ↓ (wait 100ms)           │  │  │  │   max-age=300            │    │
│  │  ┌─────────────────────┐        │  │  │  │   must-revalidate        │    │
│  │  │ Single Merged Update │        │  │  │  │                          │    │
│  │  └─────────────────────┘        │  │  │  │ ETag: "abc123def456"     │    │
│  └─────────────────────────────────┘  │  │  └──────────────────────────┘    │
│           ↓ 1 update                  │  │              ↓                     │
│                                       │  │  Client caches for 5 minutes       │
│  Config:                              │  │  Next request → "If-None-Match:"   │
│    debounce_ms: 50                    │  │  Server → "304 Not Modified"       │
│    max_batch_size: 100                │  │                                   │
│    max_wait_ms: 500                   │  │  💡 40-80% reduced server load    │
│                                       │  │  💡 Faster perceived performance   │
│  💡 70-95% fewer network requests     │  │                                   │
└───────────────────────────────────────┘  └───────────────────────────────────┘


                            ┌──────────────────────┐
                            │  Combined Result:    │
                            │                      │
                            │  🎯 Up to 99%        │
                            │  bandwidth reduction │
                            │  in optimal scenarios│
                            └──────────────────────┘



╔═══════════════════════════════════════════════════════════════════════════════╗
║                            USAGE EXAMPLE                                      ║
╚═══════════════════════════════════════════════════════════════════════════════╝

WebSocket Update Message (JSON):
┌───────────────────────────────────────────────────────────────────────────────┐
│ {                                                                             │
│   "id": "sub-123",                                                            │
│   "data": { "user": { "id": "1", "name": "Alice" } },                        │
│   "is_initial": false,                                                        │
│   "revision": 42,                                                             │
│                                                                               │
│   // ✨ Advanced Features:                                                    │
│   "cache_control": {                // Feature #4                            │
│     "max_age": 300,                 // Cache for 5 minutes                   │
│     "must_revalidate": true,                                                  │
│     "etag": "abc123"                                                          │
│   },                                                                          │
│   "changed_fields": [               // Feature #2                            │
│     "user.name"                     // Only name changed                     │
│   ],                                                                          │
│   "batched": true,                  // Feature #3                            │
│   "timestamp": 1703433600           // Server time                           │
│ }                                                                             │
└───────────────────────────────────────────────────────────────────────────────┘


╔═══════════════════════════════════════════════════════════════════════════════╗
║                        PERFORMANCE COMPARISON                                 ║
╚═══════════════════════════════════════════════════════════════════════════════╝

Scenario: Live Dashboard - 1000 users, 10 fields each, 60 updates/minute

┌──────────────────┬─────────────────┬─────────────────┬──────────────┐
│   Metric         │  Without        │  With Features  │  Improvement │
├──────────────────┼─────────────────┼─────────────────┼──────────────┤
│ Users sent       │  1000           │  100 (filtered) │  90% ↓       │
│ Fields per user  │  10             │  2 (changed)    │  80% ↓       │
│ Updates/min      │  60             │  10 (batched)   │  83% ↓       │
│ Cache hits       │  0%             │  50%            │  50% ↓ load  │
├──────────────────┼─────────────────┼─────────────────┼──────────────┤
│ Total data/min   │  ~2.3 MB        │  ~23 KB         │  99% ↓       │
└──────────────────┴─────────────────┴─────────────────┴──────────────┘


╔═══════════════════════════════════════════════════════════════════════════════╗
║                            API QUICK REFERENCE                                ║
╚═══════════════════════════════════════════════════════════════════════════════╝

use grpc_graphql_gateway::{
    parse_query_arguments,  // 1️⃣  Extract filters from query
    matches_filter,         // 1️⃣  Check if data matches filter
    detect_field_changes,   // 2️⃣  Find changed fields
    generate_cache_control, // 4️⃣  Create cache directives
    CacheControl,           // 4️⃣  Cache control struct
    DataVolatility,         // 4️⃣  Data change frequency
    BatchInvalidationConfig,// 3️⃣  Batch configuration
};

// Example: Check filtered query
let args = parse_query_arguments("users(status: ONLINE)");
if matches_filter(&args, &user_data) {
    // Include in results
}

// Example: Detect changes
let changes = detect_field_changes(&old, &new, "", 0, 10);
for change in changes {
    println!("Changed: {}", change.field_path);
}

// Example: Generate cache control
let cache = generate_cache_control(DataVolatility::Low, None);
// → max_age: 300 (5 minutes)
```