Lenses — Aquilia Documentation
Comprehensive guide and documentation for Lenses in the Aquilia framework. View API reference, examples, and implementation patterns.
import useTheme from '../../../context/ThemeContext' import CodeBlock from '../../../components/CodeBlock' import GitBranch from 'lucide-react' import NextSteps from '../../../components/NextSteps' export function ContractsLenses() const theme = useTheme() const isDark = theme === 'dark' const boxClass = `p-6 rounded-2xl border $ isDark ? 'bg-[#0A0A0A] border-white/10' : 'bg-white border-gray-200' ` return ( Contracts / Lenses Lenses Lenses are a special Facet type that renders related objects through another Contract. They provide depth-controlled, cycle-safe relational views — eliminating the need for manual nested serialization or N+1 query problems in your API responses. /* Core Concept */ Core Concept A Lens is a Facet that delegates serialization to another Contract. When the parent Contract renders, each Lens field creates an instance of the target Contract and renders the related object through it. [ title: 'Depth Control', desc: 'Maximum nesting depth prevents infinite recursion (default: 3 levels)' , title: 'Cycle Detection', desc: 'Automatically detects and prevents circular Contract references' , title: 'Projection Selection', desc: 'Choose which projection the nested Contract uses' , ].map((item, i) => ( item.title item.desc )) /* Basic Usage */ Basic Usage )
Go to Homepage