mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-21 14:31:55 +03:00
698190894f
## 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 |
||
---|---|---|
.. | ||
Body.hs | ||
Class.hs | ||
Headers.hs | ||
Method.hs | ||
QueryParams.hs | ||
Request.hs | ||
Response.hs | ||
Url.hs | ||
Validation.hs | ||
WithOptional.hs |