hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
30.98k stars 2.75k forks source link

Consistent webhook url templating for cron, event triggers, actions, remote schemas, etc #6531

Open hanakslr opened 3 years ago

hanakslr commented 3 years ago

When creating an event trigger, one is allowed to use an environment variable to define the webhook URL, which is extra helpful when working across multiple environments. The cron trigger currently must be defined with a specific URL.

Are there limitations requiring this, or can environment variables be added as an option for webhook URLs in cron triggers as well?

version: 1.3.3-cloud.3

WonderPanda commented 3 years ago

@hanakslr Environment variables should work for CRON triggers. We use this functionality heavily in our app. For example from our cron_triggers.yaml:

- name: some_cron_thing
  webhook: '{{NESTJS_EVENT_WEBHOOK_ENDPOINT}}'
  schedule: 0 0 * * *
hanakslr commented 3 years ago

@WonderPanda Ah, you are correct - thanks for pointing me in the right direction. Creating it in the yaml file and then pushing it up did the trick.

In the console, event triggers give a toggle for specifying the webhook as URL or from env var, which is what I was looking for. Additionally, when I made it through the console, even though I had "Include in metadata" turned on, it didn't show up in cron_triggers.yaml or in my migrations. Are your cron triggers showing up in your metadata if made in the console?

I can close this, but for consistency, it would probably be nice to have a similar functionality in cron triggers as event triggers to specify the URL, and have con triggers show up in the metadata if they are created in the console.

WonderPanda commented 3 years ago

@hanakslr We actually use an integration that automatically generates our CRON and event trigger configurations in the relevant YAML files so I don't create them through the console.

I agree with you that it would be ideal if the experience was the same in setting things up with the toggle for specifying if the CRON endpoint should be pulled from ENV or not. It was confusing for me the first time that there was a special handlebars syntax for interpolating env