Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit ce5d1a7

Browse files
committed
escape Cypher parameters
1 parent beb00e6 commit ce5d1a7

File tree

8 files changed

+260
-258
lines changed

8 files changed

+260
-258
lines changed

src/translate/translate.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ export const processFilterArgument = ({
14901490
: undefined;
14911491
const filterParamKey =
14921492
paramIndex > 1 ? `${paramIndex - 1}_${argumentName}` : argumentName;
1493-
const filterCypherParam = `$${filterParamKey}`;
1493+
const filterCypherParam = `$\`${filterParamKey}\``;
14941494
let translations = [];
14951495
// allows an exception for the existence of the filter argument AST
14961496
// if isFederatedOperation
@@ -2969,9 +2969,9 @@ export const translateListArguments = ({
29692969
const paramIndex = indexedParam.index;
29702970
const field = schemaType.getFields()[argumentName];
29712971
const listVariable = `${safeVariableName}.${safeVar(argumentName)}`;
2972-
let paramPath = `$${argumentName}`;
2972+
let paramPath = `$\`${argumentName}\``;
29732973
// Possibly use the already generated index used when naming nested parameters
2974-
if (paramIndex >= 1) paramPath = `$${paramIndex}_${argumentName}`;
2974+
if (paramIndex >= 1) paramPath = `$\`${paramIndex}_${argumentName}\``;
29752975
let translation = '';
29762976
if (field) {
29772977
// list argument matches the name of a field

src/utils.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export function cypherDirectiveArgs(
146146
federatedOperationParams[e] === undefined
147147
) {
148148
// Use only if value exists
149-
args.push(`${e}: $${paramIndex}_${e}`);
149+
args.push(`${e}: $\`${paramIndex}_${e}\``);
150150
}
151151
});
152152
// Return the comma separated join of all param
@@ -306,11 +306,13 @@ export function innerFilterParams(
306306
export function paramsToString(params, cypherParams) {
307307
if (params.length > 0) {
308308
const strings = _.map(params, param => {
309-
return `${param.key}:${param.paramKey ? `$${param.paramKey}.` : '$'}${
309+
return `${param.key}:${
310+
param.paramKey ? `$\`${param.paramKey}\`.` : '$`'
311+
}${
310312
!param.value || typeof param.value.index === 'undefined'
311313
? param.key
312314
: `${param.value.index}_${param.key}`
313-
}`;
315+
}\``;
314316
});
315317
return `{${strings.join(', ')}${
316318
cypherParams ? `, cypherParams: $cypherParams}` : '}'

0 commit comments

Comments
 (0)