fix(grahpql): linebreak in non-block stringValue (#4808)

master
Ika 2018-07-05 00:14:09 +08:00 committed by GitHub
parent d5a2f391cd
commit 0df2199688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View File

@ -144,7 +144,11 @@ function genericPrint(path, options, print) {
'"""'
]);
}
return concat(['"', n.value.replace(/["\\]/g, "\\$&"), '"']);
return concat([
'"',
n.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"),
'"'
]);
}
case "IntValue":
case "FloatValue":

View File

@ -49,6 +49,10 @@ Description of \`one\`
"""
one: string
}
{
foo(input: {multiline: "ab\\ncd"}) { id }
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
query X($a: Int) @relay(meta: "{\\"lowPri\\": true}") {
a
@ -113,4 +117,10 @@ input Input {
one: string
}
{
foo(input: { multiline: "ab\\ncd" }) {
id
}
}
`;

View File

@ -46,3 +46,7 @@ Description of `one`
"""
one: string
}
{
foo(input: {multiline: "ab\ncd"}) { id }
}