Back to Graphql Engine

Invoke Event Trigger Manually

docs/docs/event-triggers/invoke-trigger-manually.mdx

2.49.51.7 KB
Original Source

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import Thumbnail from '@site/src/components/Thumbnail';

Invoke Event Trigger Manually

<Tabs groupId="user-preference" className="api-tabs"> <TabItem value="console" label="Console">

You can select the Via Console trigger operation while creating an Event Trigger to allow invoking the Event Trigger on rows manually using the Hasura Console.

In the Data -> [table-name] -> Browse Rows tab, clicking the invoke trigger button next to any row lets you invoke "manual Event Triggers" configured on the table with that row as payload (the button will be shown only if you have any triggers configured):

<Thumbnail src="/img/event-triggers/select-manual-trigger.png" alt="Invoke Event Trigger on the Console" />

Click on the Event Trigger you want to run and a modal will pop up with the request and response.

<Thumbnail src="/img/event-triggers/run-manual-trigger.png" alt="Request and response of Event Trigger" /> </TabItem> <TabItem value="api" label="API">

When creating an Event Trigger over the pg_create_event_trigger Metadata API, you can set the argument enable_manual to true.

Then you can use the pg_invoke_event_trigger Metadata API to invoke triggers manually:

http
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin

{
   "type" : "pg_invoke_event_trigger",
   "args" : {
      "source": "<db_name>",
      "name": "send_email",
      "payload": {}
   }
}
</TabItem> </Tabs>