Announcing Event Triggers on Hasura GraphQL Engine
Tags: serverless, graphql, postgres
Published: 2019-12-03 12:27:17

---
title: Announcing Event Triggers on Hasura GraphQL Engine
published: true
date: 2018-09-05 00:00:00 UTC
tags: serverless, graphql, postgres
canonical_url: https://blog.hasura.io/announcing-webhook-triggers-on-database-events-for-hasura-graphql-engine-8136c15db3ef/
---

After much work and sweat over the last few months, I’m extremely happy to announce the public preview of a feature that allows you to trigger webhooks on database events!

Check it out at [https://hasura.io/event-triggers](https://hasura.io/event-triggers) and try it out on [Heroku](https://docs.hasura.io/1.0/graphql/manual/getting-started/heroku-simple.html) or with [Docker](https://docs.hasura.io/1.0/graphql/manual/getting-started/docker-simple.html).

![](https://blog.hasura.io/content/images/downloaded_images/announcing-webhook-triggers-on-database-events-for-hasura-graphql-engine-8136c15db3ef/1-rfg50zyPlOMr4tmzXk1Imw.png)

This feature is a part of the [open-source Hasura GraphQL engine](https://github.com/hasura/graphql-engine) :)

![](https://blog.hasura.io/content/images/downloaded_images/announcing-webhook-triggers-on-database-events-for-hasura-graphql-engine-8136c15db3ef/1-1vY0qPXJHww0g_1rRas-6Q.png)<figcaption>Event-triggers on Postgres with Hasura</figcaption>

With Hasura, creating an event-trigger to listen to a database change on Postgres takes all of 60 seconds:

![](https://blog.hasura.io/content/images/downloaded_images/announcing-webhook-triggers-on-database-events-for-hasura-graphql-engine-8136c15db3ef/1-3Yt2MiWp0w1QsmtgiDxRTw.gif)<figcaption>Create an event trigger for a webhook on a table</figcaption>

Coupled with serverless deployments, this allows our developers to build some really cool things very easily:

1. Push notifications that get triggered when a new review is added
2. Purge your CDN or cache to re-render your static content
3. Update a search index when a product is inserted, updated or deleted
4. Trigger business logic that can run asynchronously

Check out more use-cases, demos and tutorials on the website: [https://hasura.io/event-triggers](https://hasura.io/event-triggers)

## How it works

Triggering webhooks on events are a deceptively simple feature. However, creating events and triggering actions is something fraught with edge-cases that we’ve spent a lot of time working through. Here are some of the things you \_don’t\_ have to worry with Hasura event-triggers!

1. Atomic generation of events: If something happened in the database, then the event is captured 💯%. Any source of database changes is fair game. A GraphQL mutation, a legacy REST API, a cron-job, direct SQL changes. In fact, events are even captured if Hasura is not running, going through a restart or deployment rollout.
2. Reliable delivery of events: You can configure retry logic and a retry interval.
3. Horizontally scalable: You want to deliver more events faster? Just scale Hasura horizontally and stay calm.
4. Debugging and Observability: Building async logic, especially with serverless functions, is so much fun when you’re trying things out and simultaneously so much nightmare in production. A large part of this is because debugging and tracing events in the new sphagetti backend requires extra instrumentation. With Hasura, events & invocations are already instrumented and the highly structured and informative logs make it easy for you to trace everything from errors to latency issues with your favourite tools :)

## Realtime GraphQL ❤️ Serverless triggered by database events

I’m personally the most excited about the killer combination of realtime GraphQL (live-queries) and async business logic.

{% gist https://gist.github.com/coco98/2d3ed7cab8196d566b99f6b8f514caf7.js %}

I’ve put together a video describing what an app using serverless for complex business logic in a real world situation would look like and it’s super fun to look at!

{% youtube kTSOxRrtCeI %}
## Try it out!

This is a public preview release and we’re eagerly waiting to hear what you think. Take it for a spin at [https://hasura.io/event-triggers](https://hasura.io/event-triggers) and try it out on [Heroku](https://docs.hasura.io/1.0/graphql/manual/getting-started/heroku-simple.html) or with [Docker](https://docs.hasura.io/1.0/graphql/manual/getting-started/docker-simple.html).