graphql-engine/server/src-lib/Hasura/RQL/DDL/Webhook/Transform
Puru Gupta 698190894f server: use kriti template to generate query param from list
## Description ✍️
This PR adds support to generate query params directly using a kriti template which can be used to flatten a list of parameter arguments as well.

### Changes in the Metadata API
Earlier the `query_params` key inside `request_transform` used to take in an object of key/value pairs where the `key` represents the query parameter name and `value` points to the value of the parameter or a kriti template which could be resolved to the value.

With this PR, we provide the user with more freedom to generate the complete query string using kriti template. The  `query_params` can now take in a string as well which will be a kriti template. This new change needs to be incorporated on the console and CLI metadata import/export as well.
- [x] CLI: Compatible, no changes required
- [ ] Console

## Changelog ✍️

__Component__ : server

__Type__: feature

__Product__: community-edition

### Short Changelog

use kriti template to generate query param from list of arguments

### Related Issues ✍
https://hasurahq.atlassian.net/browse/GS-243

### Solution and Design ✍
We use a kriti template to generate the complete query parameter string.

| Query Template | Output |
|---|---|
| `{{ concat ([concat({{ range _, x := [\"apple\", \"banana\"] }} \"tags={{x}}&\" {{ end }}), \"flag=smthng\"]) }}`| `tags=apple&tags=banana&flag=smthng`  |
| `{{ concat ([\"tags=\", concat({{ range _, x := $body.input }} \"{{x}},\" {{ end }})]) }}` | `tags=apple%2Cbanana%2C` |

### Steps to test and verify ✍
- start HGE and make the following request to `http://localhost:8080/v1/metadata`:
```json
{
    "type": "test_webhook_transform",
    "args": {
        "webhook_url": "http://localhost:3000",
        "body": {
            "action": {
                "name": "actionName"
            },
            "input": ["apple", "banana"]
        },
        "request_transform": {
            "version": 2,
            "url": "{{$base_url}}",
            "query_params": "{{ concat ([concat({{ range _, x := $body.input }} \"tags={{x}}&\" {{ end }}), \"flag=smthng\"]) }}",
            "template_engine": "Kriti"
        }
    }
}
```
- you should receive the following as output:
```json
{
    "body": {
        "action": {
            "name": "actionName"
        },
        "input": [
            "apple",
            "banana"
        ]
    },
    "headers": [],
    "method": "GET",
    "webhook_url": "http://localhost:3000?tags=apple&tags=banana&flag=smthng"
}
```

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6961
Co-authored-by: Tirumarai Selvan <8663570+tirumaraiselvan@users.noreply.github.com>
GitOrigin-RevId: 712ba038f03009edc3e8eb0435e723304943399a
2022-11-29 20:27:41 +00:00
..
Body.hs server: delete the Cacheable type class in favor of Eq 2022-11-21 16:35:37 +00:00
Class.hs server: delete the Cacheable type class in favor of Eq 2022-11-21 16:35:37 +00:00
Headers.hs server: delete the Cacheable type class in favor of Eq 2022-11-21 16:35:37 +00:00
Method.hs server: delete the Cacheable type class in favor of Eq 2022-11-21 16:35:37 +00:00
QueryParams.hs server: use kriti template to generate query param from list 2022-11-29 20:27:41 +00:00
Request.hs server: delete the Cacheable type class in favor of Eq 2022-11-21 16:35:37 +00:00
Response.hs Webhook Transforms: Move RequestCtx into a type family 2022-10-16 03:55:06 +00:00
Url.hs server: delete the Cacheable type class in favor of Eq 2022-11-21 16:35:37 +00:00
Validation.hs server: fix template validation behaviour 2022-11-16 16:37:34 +00:00
WithOptional.hs server: delete the Cacheable type class in favor of Eq 2022-11-21 16:35:37 +00:00