2020-01-14 15:57:45 +03:00
|
|
|
.. meta::
|
|
|
|
:description: Create an event trigger with Hasura
|
|
|
|
:keywords: hasura, docs, event trigger, create
|
|
|
|
|
2020-03-11 22:42:36 +03:00
|
|
|
.. _create_trigger:
|
|
|
|
|
2018-09-11 14:11:24 +03:00
|
|
|
Creating an event trigger
|
|
|
|
=========================
|
|
|
|
|
2018-12-03 15:12:24 +03:00
|
|
|
.. contents:: Table of contents
|
|
|
|
:backlinks: none
|
|
|
|
:depth: 1
|
|
|
|
:local:
|
|
|
|
|
2019-05-13 12:41:07 +03:00
|
|
|
Event triggers can be created using the Hasura console or metadata APIs.
|
2018-09-11 14:11:24 +03:00
|
|
|
|
2019-05-13 12:41:07 +03:00
|
|
|
Open the Hasura console, head to the ``Events`` tab and click on the ``Create`` button to open the
|
|
|
|
page below:
|
2018-09-11 14:11:24 +03:00
|
|
|
|
2019-03-13 13:03:45 +03:00
|
|
|
.. thumbnail:: ../../../img/graphql/manual/event-triggers/create-event-trigger.png
|
2020-01-08 16:20:18 +03:00
|
|
|
:alt: Create an event trigger
|
2018-09-11 14:11:24 +03:00
|
|
|
|
2018-10-27 07:59:54 +03:00
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
|
|
|
|
**Trigger Name**
|
|
|
|
|
|
|
|
Unique name for event trigger.
|
|
|
|
|
|
|
|
**Schema/Table**
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
The postgres schema and table name on which the event trigger needs to be created.
|
2018-10-27 07:59:54 +03:00
|
|
|
|
2019-05-13 12:41:07 +03:00
|
|
|
**Trigger Operations**
|
2018-10-27 07:59:54 +03:00
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
The table operation on which the event trigger will be invoked.
|
2018-10-27 07:59:54 +03:00
|
|
|
|
|
|
|
**Webhook URL**
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
The HTTP(s) URL which will be called with the event payload on configured operation. Must be a ``POST`` handler. This URL
|
2018-12-05 08:13:13 +03:00
|
|
|
can be entered manually or can be picked up from an environment variable (*the environment variable needs to be set
|
|
|
|
before using it for this configuration*).
|
2018-10-27 07:59:54 +03:00
|
|
|
|
|
|
|
Advanced Settings
|
|
|
|
-----------------
|
|
|
|
|
2019-03-13 13:03:45 +03:00
|
|
|
.. thumbnail:: ../../../img/graphql/manual/event-triggers/create-event-trigger-advanced-settings.png
|
2020-01-08 16:20:18 +03:00
|
|
|
:alt: Advanced settings for event triggers
|
2018-12-05 08:13:13 +03:00
|
|
|
|
2018-10-27 07:59:54 +03:00
|
|
|
Listen columns for update
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
Update operations are special because you may want to trigger a webhook only if specific columns have changed in a row.
|
|
|
|
Choose the columns here which you want the update operation to listen to.
|
2018-10-27 07:59:54 +03:00
|
|
|
|
2019-05-13 12:41:07 +03:00
|
|
|
If a column is not selected here, then an update to that column will not trigger the webhook.
|
2018-10-27 07:59:54 +03:00
|
|
|
|
|
|
|
|
|
|
|
Retry Logic
|
|
|
|
^^^^^^^^^^^
|
|
|
|
|
2018-09-11 14:11:24 +03:00
|
|
|
Retry configuration is available in the "Advanced settings" when you create a trigger.
|
|
|
|
|
2019-05-13 12:41:07 +03:00
|
|
|
1. ``num_retries``: Number of times a failed invocation is retried. Default value is **0**.
|
|
|
|
2. ``interval_sec``: Number of seconds after which a failed invocation is retried. Default value is **10**.
|
|
|
|
3. ``timeout_sec``:: Number of seconds before which client closes the connection to the webhook. Default value is **60**.
|
2018-10-27 07:59:54 +03:00
|
|
|
|
|
|
|
Headers
|
|
|
|
^^^^^^^
|
|
|
|
|
|
|
|
Custom headers can be added to an event trigger. Each webhook request will have these headers added.
|
|
|
|
|
|
|
|
Each header has 3 parameters:
|
|
|
|
|
|
|
|
1. ``Key``: Name of the header e.g. Authorization or X-My-Header.
|
2018-12-05 08:13:13 +03:00
|
|
|
2. ``Type``: One of ``static`` or ``from env variable``. ``static`` means the value provided in the ``Value`` field is
|
|
|
|
the raw value of the header. ``from env variable`` means the value provided in the ``Value`` field is the name of
|
2019-09-11 10:17:14 +03:00
|
|
|
the environment variable in the GraphQL engine which will be resolved before sending the header.
|
|
|
|
3. ``Value``: The value of the header. Either a static value or the name of an environment variable.
|