Batching & dedup
All fetches for the same source are batched into one call. Duplicate IDs across the tree are fetched once.
Declare which fields are IDs, get fully resolved objects back. Batched, deduplicated, cached.
const ticket = await fetchTicket('t-1');
const assignee = ticket.assigneeId ? await fetchUser(ticket.assigneeId) : null;
const watchers = await Promise.all(ticket.watcherIds.map(id => (id ? fetchUser(id) : null)));
// 3 network calls, no batching, no types, repeat per field...const refs = defineReferences(c => ({
User: c.source<User>({ batch: ids => fetchUsers(ids) }),
}));
const result = await refs.inline(ticket, {
fields: { assigneeId: 'User', watcherIds: 'User' },
});
result.assigneeIdT; // User | null
result.watcherIdTs; // (User | null)[]
// 1 network call, all IDs batched, fully typedAI / LLM integration — Machine-readable docs available at llms.txt and ship with the npm package.