hasura / hasura/graphql-engine
Add support for request headers transform in Actions
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Is your proposal related to a problem?
I am trying to define an action that calls an external service. This service requires a specific Cookie to be present in the request headers for authentication, which the user should already have at the tame of calling the action.
However, I am not able to figure out a way to pass the cookie value to my webhook handler. I first tried using the `Forward client headers to webhook` option, but it doesn't seem to forward the `Cookie` header.
My idea was then to save the cookie token as part of my session variables (which we can do in our authentication service), and use a header transform to forward it to the webhook:
```
Cookie: {{$session_variables["x-hasura-my-token']}}
```
It is then that I realized headers transform is not actually supported according to [the documentation](https://hasura.io/docs/latest/actions/rest-connectors/#action-transform-types), resulting in the following error when calling the action:
```
{
"errors": [
{
"message": "template cannot be resolved: $session_variables[\"x-hasura-my-token']",
"extensions": {
"path": "$",
"code": "not-found"
}
}
]
}
```
### Describe the solution you'd like
Ideally, it would be great if headers transform could be supported similarly to request body and url to make the above possible.
### Describe alternatives you've considered
Alternately, allowing `Cookie` headers to be forwarded to the webhook could solve this specific use case.
Contributor guide
Assessment
This issue has not been assessed yet.