When a chained parameter can be resolved due to the source resource not having the field, restQL won't send the value to the downstream API. However, if the _debug query parameter is provided when running the query, a debug section will be returned inside details. In this debug section, all query parameters sent to the API as listed, but the unresolved one which was not sent is returned too, with a garbage value.
Expected Behavior
from hero
with
id = "1234"
from sidekick
with
id = hero.sidekickId
someFilter = "abc"
foo = hero.foo
Running this query with the _debug=true will return:
{
"hero": { /* usual restQL response */ },
"sidekick": {
"details": {
"status": 200,
"success": true,
"metadata": {},
"debug": {
"method": "GET",
"url": "http://heros/api/sidekick/myid?someFilter=abc",
"request-headers": { /* headers sent to downstream API */ },
"response-headers": { /* headers return by downstream API */ },
"params": { "someFilter": "abc" },
"response-time": 1
}
},
"result": { /* some data */ }
}
}
Should return only the parameters sent to the downstream API.
Current Behavior
When running the same query above it returns the following:
{
"hero": { /* usual restQL response */ },
"sidekick": {
"details": {
"status": 200,
"success": true,
"metadata": {},
"debug": {
"method": "GET",
"url": "http://heros/api/sidekick/myid?someFilter=abc",
"request-headers": { /* headers sent to downstream API */ },
"response-headers": { /* headers return by downstream API */ },
"params": {
"someFilter": "abc",
"foo": [
"hero",
"foo"
]
},
"response-time": 1
}
},
"result": { /* some data */ }
}
}
Possible Solution
When the internal HTTP client converts the value from interface{} to the string in order to build the query parameters it parses only the Go primitive types (string, int, float, slice, maps) and hence avoid the unresolved variable which still has a value of type Chained.
Although this casting is necessary, the filtering of unresolved values happens as a side effect of it. When building the HTTPRequest at the runner package we should filter these unresolved values to never be passed to the HTTP Client or anyone how expects an HTTPRequest, like the LifecyclePlugin hook BeforeRequest.
When a chained parameter can be resolved due to the source resource not having the field, restQL won't send the value to the downstream API. However, if the
_debug
query parameter is provided when running the query, adebug
section will be returned insidedetails
. In this debug section, all query parameters sent to the API as listed, but the unresolved one which was not sent is returned too, with a garbage value.Expected Behavior
Running this query with the
_debug=true
will return:Should return only the parameters sent to the downstream API.
Current Behavior
When running the same query above it returns the following:
Possible Solution
When the internal HTTP client converts the value from
interface{}
to thestring
in order to build the query parameters it parses only the Go primitive types (string, int, float, slice, maps) and hence avoid the unresolved variable which still has a value of typeChained
.Although this casting is necessary, the filtering of unresolved values happens as a side effect of it. When building the
HTTPRequest
at therunner
package we should filter these unresolved values to never be passed to the HTTP Client or anyone how expects anHTTPRequest
, like theLifecyclePlugin
hookBeforeRequest
.