Skip to main content

Module cascade_response_parser

Module cascade_response_parser 

Source
Expand description

Parser for GraphQL Cascade responses to extract entity invalidation data.

This module parses GraphQL mutation responses following the GraphQL Cascade specification, extracting all affected entities (updated and deleted) to enable entity-level cache invalidation.

§Architecture

GraphQL Mutation Response
┌──────────────────────────────────┐
│ {                                │
│   "createPost": {                │
│     "post": { ... },             │
│     "cascade": {                 │
│       "updated": [               │
│         {                        │
│           "__typename": "User",  │
│           "id": "uuid-123",      │
│           ...                    │
│         }                        │
│       ],                         │
│       "deleted": [ ... ]         │
│     }                            │
│   }                              │
│ }                                │
└──────────────────────────────────┘
           │
           ↓ parse_cascade_response()
┌──────────────────────────────────┐
│ CascadeEntities:                 │
│ updated: [                       │
│   EntityKey("User", "uuid-123")  │
│ ]                                │
│ deleted: []                      │
└──────────────────────────────────┘

§Examples

use fraiseql_core::cache::CascadeResponseParser;
use serde_json::json;

let parser = CascadeResponseParser::new();

let response = json!({
  "createPost": {
    "cascade": {
      "updated": [
        { "__typename": "User", "id": "550e8400-e29b-41d4-a716-446655440000" }
      ]
    }
  }
});

let entities = parser.parse_cascade_response(&response)?;
assert_eq!(entities.updated.len(), 1);
assert_eq!(entities.updated[0].entity_type, "User");

Structs§

CascadeEntities
Cascade entities extracted from a GraphQL mutation response.
CascadeResponseParser
Parser for GraphQL Cascade responses following the Cascade specification v1.1.