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. invoke passes the call to the runner. A local Frond runs in memory; a Frond declared in remotes uses JSON-RPC.
  • State forwarding. In a request, invoke adds the current session to invocation state. Outside a request, state is empty or provided explicitly.
  • Errors are the same FougereErrors — a bridge maps them with toHttpError if 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.

Built with Fougere — this site runs on the framework it documents.