The Bridge of Realms
Decoupling a mystical abstraction from its earthly implementation.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Bridge
ARCANUM SCHOOL: Transmutation // Abstraction
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
# The Abstraction
interface SpellcastingAbility {
castSpell(name: String!): String!
manaCost: Int!
}
# Implementation A
type Wizard implements SpellcastingAbility {
castSpell(name: String!): String!
manaCost: Int!
grimoire: String!
}
# Implementation B
type Sorcerer implements SpellcastingAbility {
castSpell(name: String!): String!
manaCost: Int!
bloodline: String!
}
type Query {
# The client queries the abstraction, indifferent to the underlying implementation
fetchCasters: [SpellcastingAbility!]!
}
The Bridge pattern uses GraphQL interfaces to decouple the definition of a capability (the abstraction) from its specific implementation. A client can interact with SpellcastingAbility without caring whether a Wizard or Sorcerer fulfills the contract.
Runic Tags:
#graphql
#structural
#bridge
#interfaces