[Graphql] Escape strings (#3143)

When I ran it on all the graphql files of fb, none of them had escape, but someone reported this issue!
This commit is contained in:
Christopher Chedeau authored and GitHub committed 2017-11-04 11:04:45 -07:00
1 parent bb145c19c1
commit ec18ebc6c6
4 files changed
+13 -1

No files matched your search

+1 -1
View File
@@ -108,7 +108,7 @@ function genericPrint(path, options, print) {
return n.value;
}
case "StringValue": {
return concat(['"', n.value, '"']);
return concat(['"', n.value.replace(/["\\]/g, "\\$&"), '"']);
}
case "IntValue":
case "FloatValue":
@@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`string.graphql 1`] = `
query X($a: Int) @relay(meta: "{\\"lowPri\\": true}") { a }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
query X($a: Int) @relay(meta: "{\\"lowPri\\": true}") {
a
}
`;
+1
View File
@@ -0,0 +1 @@
run_spec(__dirname, { parser: "graphql" });
+1
View File
@@ -0,0 +1 @@
query X($a: Int) @relay(meta: "{\"lowPri\": true}") { a }