Inconsistent interpolation behavior in various parts of the configuration
Describe the bug
Inconsistent interpolation behavior in various parts of the configuration. In current state, when endpoint has one or more parameters, the parameters can be used in url_pattern freely. When using endpoint parameters in backend/graphql variables, it is not possible to have a string containing multiple parameters as in url_pattern.
I believe the bug is in https://github.com/luraproject/lura/blob/faec9df8281ad5738e34eb081af5ce1a232ec59e/transport/http/client/graphql/graphql.go#L97-L105
With url_pattern the logic is reversed and all parameters are replaced in one go by transforming {paramater} to a Go template variable {{ .parameter }}.
https://github.com/luraproject/lura/blob/faec9df8281ad5738e34eb081af5ce1a232ec59e/config/config.go#L579
To Reproduce Steps to reproduce the behavior:
- Configuration used: endpoint configuration
{
"endpoint": "/v1/{owner}/{repo}/announcements",
"method": "GET",
"output_encoding": "json",
"backend": [
{
"url_pattern": "/api/graphql",
"encoding": "json",
"target": "data.search",
"sd": "static",
"method": "POST",
"extra_config": {
"backend/graphql": {
"type": "query",
"query_path": "./graphql/github.announcements.graphql",
"variables": {
"query": "repo:{owner}/{repo} category:Announcements label:component:rollout"
}
},
"modifier/martian": {
"header.Modifier": {
"scope": ["request"],
"name": "Authorization",
"value": "Bearer {{ env "GITHUB_TOKEN" }}"
}
}
},
"host": [
"https://github.com"
],
"disable_host_sanitize": false
}
]
}- Configuration is used with krakend.
Expected behavior
Endpoint parameter interpolation will work consistently in all elements of configuration where parameters are allowed to be used. In above example, is this part:
"query": "repo:{owner}/{repo} category:Announcements label:component:rollout"
Logs No logs, as there are no errors in this use case. Just a bad query is passed to graphql request, but returning empty result.
Additional context GraphQL doesn't have string interpolation and this functionality will help preparing variables before being passed to the GraphQL request.
Source: luraproject/lura