Triggers on agent component tables
- Dominant language
- TypeScript
- Stars
- 349
- Forks
- 92
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 24
Description
I tried to add support for triggers on agent component tables by following the [convex-helpers `Triggers` docs](https://github.com/get-convex/convex-helpers). The setup works when I register triggers inside the agent component package itself, but it does **not** work when I expose `triggers` and register them in example apps.
I’d like help understanding why this discrepancy happens and how to fix it.
---
### Steps Taken
1. Added `triggers.ts` with the following code:
```ts
import { mutation as rawMutation, internalMutation as rawInternalMutation } from "./_generated/server.js";
import type { DataModel } from "./_generated/dataModel.js";
import { Triggers } from "convex-helpers/server/triggers";
import { customCtx, customMutation } from "convex-helpers/server/customFunctions";
const triggers: Triggers = new Triggers();
export const mutation = customMutation(rawMutation, customCtx(triggers.wrapDB));
export const internalMutation = customMutation(
rawInternalMutation,
customCtx(triggers.wrapDB),
);
export { triggers };
```
2. Updated all mutations to use this new `mutation` wrapper.
---
### Problem
* ✅ Triggers work fine when registered **inside the agent component package**.
* ❌ Triggers do not fire when I **expose `triggers` and register them in example apps**.
---
### Question
What could be causing triggers to fail when registered outside the component package?
Contributor guide
Assessment
This issue has not been assessed yet.