✨ ARCANUM RUNE DIFFICULTY: Archmage Structural

The Flyweight Nodes

Minimizing memory consumption by sharing common entity structures.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Transmutation // Optimization
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
# The shared Flyweight interface
interface Node {
  id: ID!
}

type SharedSpell implements Node {
  id: ID! # A globally unique ID for caching
  incantation: String!
  baseDamage: Int!
}

type Wizard {
  name: String!
  # Instead of duplicating the spell data, we link to the shared flyweight node
  knownSpells: [SharedSpell!]!
}

In the Graph Oracle, the Flyweight pattern is implemented via global object identification (the Relay Node interface). By ensuring each entity has a globally unique ID, client-side caches (like Apollo or Relay) can store a single instance of an object in memory and reference it endlessly, saving vital resources.

Runic Tags: #graphql #structural #flyweight #node #cache #relay