Add support for arguments with soft line break (#1993)
parent
8cb259eac7
commit
df08dc4a56
|
@ -7,6 +7,7 @@ const hardline = docBuilders.hardline;
|
|||
const softline = docBuilders.softline;
|
||||
const group = docBuilders.group;
|
||||
const indent = docBuilders.indent;
|
||||
const ifBreak = docBuilders.ifBreak;
|
||||
|
||||
function genericPrint(path, options, print) {
|
||||
const n = path.getValue();
|
||||
|
@ -52,7 +53,7 @@ function genericPrint(path, options, print) {
|
|||
concat([
|
||||
softline,
|
||||
join(
|
||||
concat([",", softline]),
|
||||
concat([",", ifBreak("", " "), softline]),
|
||||
path.map(print, "arguments")
|
||||
)
|
||||
])
|
||||
|
@ -73,6 +74,18 @@ function genericPrint(path, options, print) {
|
|||
case "StringValue": {
|
||||
return concat(['"', n.value, '"']);
|
||||
}
|
||||
case "IntValue": {
|
||||
return n.value;
|
||||
}
|
||||
case "FloatValue": {
|
||||
return n.value;
|
||||
}
|
||||
case "BooleanValue": {
|
||||
return n.value ? 'true' : 'false';
|
||||
}
|
||||
case "Variable": {
|
||||
return concat(["$", path.call(print, "name")])
|
||||
}
|
||||
case "Argument": {
|
||||
return concat([
|
||||
path.call(print, "name"),
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`hello.graphql 1`] = `
|
||||
{
|
||||
short(var: $var, int: 5, float: 5.6, bool: true, string: "hello world!")
|
||||
long(var: $thisIsAReallyLongVariableNameRight, int: 52342342342, float: 5.6, bool: true, string: "hello world this is a very long string!")
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
{
|
||||
short(var: $var, int: 5, float: 5.6, bool: true, string: "hello world!") long(
|
||||
var: $thisIsAReallyLongVariableNameRight,
|
||||
int: 52342342342,
|
||||
float: 5.6,
|
||||
bool: true,
|
||||
string: "hello world this is a very long string!"
|
||||
)
|
||||
}
|
||||
|
||||
`;
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
short(var: $var, int: 5, float: 5.6, bool: true, string: "hello world!")
|
||||
long(var: $thisIsAReallyLongVariableNameRight, int: 52342342342, float: 5.6, bool: true, string: "hello world this is a very long string!")
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname, { parser: "graphql" });
|
Loading…
Reference in New Issue