Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add action-style templating of webhook URL for event trigger and remote schemas #2483

Closed
marionschleifer opened this issue Jul 8, 2019 · 21 comments · Fixed by #5760
Closed
Assignees
Labels
c/server Related to server p/high candidate for being included in the upcoming sprint p/medium non-urgent issues/features that are candidates for being included in one of the upcoming sprints
Milestone

Comments

@marionschleifer
Copy link
Contributor

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.

@marionschleifer marionschleifer added p/medium non-urgent issues/features that are candidates for being included in one of the upcoming sprints c/event-triggers labels Jul 8, 2019
@tirumaraiselvan
Copy link
Contributor

tirumaraiselvan commented Jul 8, 2019

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

@tirumaraiselvan tirumaraiselvan added the e/intermediate can be wrapped up in a week label Jul 8, 2019
@flybayer
Copy link

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

@carllippert
Copy link

+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

@gunar
Copy link

gunar commented Dec 30, 2019

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");
}

@jchonde
Copy link

jchonde commented May 7, 2020

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.

@rikinsk rikinsk added the c/server Related to server label May 7, 2020
@tirumaraiselvan tirumaraiselvan changed the title Templating of webhook URL add action-style templating of webhook URL for event trigger May 8, 2020
@tirumaraiselvan tirumaraiselvan removed the e/intermediate can be wrapped up in a week label May 8, 2020
@tirumaraiselvan
Copy link
Contributor

tirumaraiselvan commented May 8, 2020

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

@amille14
Copy link

amille14 commented Jun 4, 2020

@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.

@rikinsk
Copy link
Member

rikinsk commented Jun 5, 2020

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

@sahanatroam
Copy link

similar issue: #5090

@dan-lee
Copy link

dan-lee commented Jul 3, 2020

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

@ancs21
Copy link

ancs21 commented Aug 25, 2020

Hello @rikinsk ,

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

Please update ASAP. Thanks.

@tirumaraiselvan tirumaraiselvan changed the title add action-style templating of webhook URL for event trigger add action-style templating of webhook URL for event trigger and remote schemas Aug 31, 2020
@tirumaraiselvan tirumaraiselvan added p/high candidate for being included in the upcoming sprint and removed c/event-triggers labels Aug 31, 2020
@nksaraf
Copy link

nksaraf commented Sep 2, 2020

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

@smblee
Copy link

smblee commented Oct 7, 2020

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

@ancs21
Copy link

ancs21 commented Oct 7, 2020

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

@tirumaraiselvan tirumaraiselvan added this to the v1.3.3 milestone Nov 18, 2020
@adventurini
Copy link

Is this feature released yet?

@picosam
Copy link

picosam commented Jan 19, 2021

@tirumaraiselvan I'm unable to use this even though you supposedly released it in v1.3.3 -- am I missing something?

@kedarguy
Copy link

@adventurini @tirumaraiselvan It's working for me on 1.3.3

@tobiastornros
Copy link
Contributor

Thanks for including this in 1.3.3 @tirumaraiselvan

I think that both Hasura UI and Docs should be updated to reflect this change.

Here is how you use it @adventurini @picosam

image

@picosam
Copy link

picosam commented Jan 19, 2021

Ohhhh so we should use URL. Sorry, I kept using environment variables!

@adventurini
Copy link

Yes, I was doing the same thing @picosam. Also, docs should be updated for the current language of:

Alternatively, environment variables can also be read from the .env file, created manually by the user, at the **_project root directory._** A global flag, --envfile, is available to explicitly get the .env file created by the user, which defaults to .env if no flag is provided.

The project root directory is confusing. It should state the hasura generated root directory -- I also understand that many people will understand the difference and what the docs meant, but it is still not clear.

@ericxiao251
Copy link

Hey folks, is there an example of the env file structure? I'm getting Value for environment variables not found: errors when trying to access my webhook. This is an example URL:

{
  "SOME_WEBHOOK_URL": "https://some_url",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/server Related to server p/high candidate for being included in the upcoming sprint p/medium non-urgent issues/features that are candidates for being included in one of the upcoming sprints
Projects
None yet
Development

Successfully merging a pull request may close this issue.