Graphql-engine: add action-style templating of webhook URL for event trigger and remote schemas

Created on 8 Jul 2019  路  14Comments  路  Source: hasura/graphql-engine

So far, when creating an event trigger and select a webhook url, we have the option to use environment variables but we cannot use string templates yet. Add support to be able to use string templates.

server high medium

Most helpful comment

I would expect the webhook url to behave like the action's http handler. eg: {{SERVICE_BASE_URL}}/my_endpoint
That would make things consistent if not useful.

All 14 comments

TBD:

  1. What are the constraints on the template?

Do we allow ${WEBHOOK_BASE_DOMAIN}/hook-1 and also http://something.com/${NAMESPACE}/hook-2

  1. What is the templating syntax? BASH like variable expansion?
    So ${WEBHOOK_BASE_DOMAIN}/hook-3 is different from ${WEBHOOK_BASE}_DOMAIN/hook-3

I would very much appreciate this feature! Currently I'm adding a new env variable for every single event.

+1 This would be an excellent addition for those heavily leaning on events and solve some of the whole metadata swaps people have been talking about to get around env var problems with migrations

Alternative: The payload includes trigger.name so you could point all events to a single endpoint and do the routing on the server side.

if (payload.trigger.name === "user_added") {
  // ...
} else if (payload.trigger.name === "user_removed") {
  // ...
} else {
  throw Error("unexpected event");
}

I would expect the webhook url to behave like the action's http handler. eg: {{SERVICE_BASE_URL}}/my_endpoint
That would make things consistent if not useful.

Yes, making it consistent is definitely something that should be done. The webhook key in event trigger APIs can take a templated url, just like in Actions. The webhook_from_env key remains unchanged for backward-compatibility.

Changing title to reflect this feature

@tirumaraiselvan is your last comments saying that this already exists for the webhook key for event triggers, or just that it is a planned feature? I need this feature as well to enable working with a vercel serverless api for my events. Having it work exactly like action webhook templated urls would be great.

When I tested it on v1.2.2 it didn't seem to work for events.

@amille14 This is not available now. Its a planned feature.

@gunar That's a great workaround! Should be easy to migrate after this feature's available

Hello @rikinsk ,

Amazing method for DX.
Currently, my team is migrating manual metadata.

Please update ASAP. Thanks.

Would love to have this feature!! Using remote schemas and events extensively.

What's the status on this issue? I see the pull request but I am unable to use handlebars to set the URLs still

@smblee I think this feature release in the next version.

Was this page helpful?
0 / 5 - 0 ratings