Skip to content

Triggers on agent component tables #147

@alifarooq9

Description

@alifarooq9

I tried to add support for triggers on agent component tables by following the convex-helpers Triggers docs. 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:
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<DataModel> = new Triggers<DataModel>();

export const mutation = customMutation(rawMutation, customCtx(triggers.wrapDB));
export const internalMutation = customMutation(
  rawInternalMutation,
  customCtx(triggers.wrapDB),
);

export { triggers };
  1. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions