invoke
invoke calls a Frond operation from the server without reactive state. It is used in
server routes, scheduled tasks, and protocol adapters.
// server/api/feed.xml.get.ts — an RSS bridge in three moves: parse → invoke → format
import Post from '@frond/blog/entities/Post';
export default defineEventHandler(async (event) => {
const posts = await invoke<PostCard[]>(Post, 'list');
return renderRss(posts);
});
Signatures
invoke<T>(Entity, op, input?) // designation by class
invoke<T>({ entity, op }, input?) // raw form, for dynamic bridges
// input: { params?, query?, body? }
Semantics
- Local or remote routing.
invokepasses the call to the runner. A local Frond runs in memory; a Frond declared inremotesuses JSON-RPC. - State forwarding. In a request,
invokeadds the current session to invocation state. Outside a request, state is empty or provided explicitly. - Errors are the same
FougereErrors — a bridge maps them withtoHttpErrorif it speaks HTTP, or lets them propagate.
Boundary
invoke is for Frond operations only. Services, Logger, Config come from the
container (DI) — invoke is not a service locator.
The provided REST and GraphQL adapters follow the same sequence: parse → invoke → format. A custom adapter can use the same structure.
Next: The gradient — moving a Frond out of process.