Fix to ignore global rest query headers when they are not configured.

This commit is contained in:
Dean 2022-06-15 10:09:47 +01:00
parent 6e15901847
commit 57b8ae7842
2 changed files with 9 additions and 5 deletions

View File

@ -9,7 +9,9 @@ export function enrichQueryFields(
parameters = {}
) {
const enrichedQuery: { [key: string]: any } = Array.isArray(fields) ? [] : {}
if (!fields || !parameters) {
return enrichedQuery
}
// enrich the fields with dynamic parameters
for (let key of Object.keys(fields)) {
if (fields[key] == null) {

View File

@ -47,10 +47,12 @@ class QueryRunner {
const enrichedContext = { ...enrichedParameters, ...this.ctx }
// Parse global headers
if (datasource.config.defaultHeaders) {
datasource.config.defaultHeaders = enrichQueryFields(
datasource.config.defaultHeaders,
enrichedContext
)
}
let query
// handle SQL injections by interpolating the variables