Type Alias: HoleResolver
HoleResolver = (
context) =>Promise<unknown>
Defined in: holes.types.ts:79
The consumer's answer to "what goes in this field": one async function, called once per hole per render, returning the value that field should hold.
Where the value lands is the renderer's business — it is written back at the hole's dotted path before the block is invoked, so the block reads it as an ordinary prop and cannot tell a resolved field from a frozen one. What the value is, and what caching or fetching produces it, is entirely this function's.
It is handed the field's spec and never a stored value: compile discarded whatever the author
had typed into a field it turned into a hole, so there is no placeholder to fall back on. Turning
spec.revalidate into a framework's caching options is the framework binding's job —
@nubbin/next ships holeFetchOptions for exactly that.
Parameters
context
The hole being asked for: route, node, block, dotted path and spec. See HoleContext.
Returns
Promise<unknown>
The field's value, in the shape the block's schema described at that path. Nothing re-validates it — the artifact was validated at compile and this value was not there then — so a resolver returning the wrong shape reaches the component unchallenged.
Throws
Nothing is caught. A rejection propagates out of Renderer and fails the render, rather
than rendering the node with the field missing.
Example
Map the field's declared lifecycle onto a caching layer
import type { HoleResolver } from "@nubbin/react";
const resolveHole: HoleResolver = async ({ block, path, spec }) => {
const response = await fetch(`https://api.example.com/${block}/${path}`, {
next: { revalidate: spec.revalidate },
});
return response.json();
};