Add support for GraphQL object values (#2010)

master
Sashko Stubailo 2017-06-06 14:28:15 -07:00 committed by Christopher Chedeau
parent c441f87fc0
commit 7c051804a8
4 changed files with 56 additions and 0 deletions

View File

@ -130,6 +130,27 @@ function genericPrint(path, options, print) {
])
);
}
case "ObjectValue": {
return group(
concat([
"{",
n.fields.length > 0 ? " " : "",
indent(
concat([
softline,
join(
concat([",", ifBreak("", " "), softline]),
path.map(print, "fields")
)
])
),
softline,
ifBreak("", n.fields.length > 0 ? " " : ""),
"}"
])
);
}
case "ObjectField":
case "Argument": {
return concat([
path.call(print, "name"),

View File

@ -0,0 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`objects.graphql 1`] = `
{
shortWithObj(obj: { hello: "world", x: 5 })
multilineObj(obj: {
hello: "world",
x: 5
})
longWithObj(obj: { ,,longString: "hello world this is a very long string!", list: [1, 2, 3, 4, 5, 6, 7] })
emptyObj(arg: {})
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
shortWithObj(obj: { hello: "world", x: 5 })
multilineObj(obj: { hello: "world", x: 5 })
longWithObj(
obj: {
longString: "hello world this is a very long string!",
list: [1, 2, 3, 4, 5, 6, 7]
}
)
emptyObj(arg: {})
}
`;

View File

@ -0,0 +1 @@
run_spec(__dirname, { parser: "graphql" });

View File

@ -0,0 +1,9 @@
{
shortWithObj(obj: { hello: "world", x: 5 })
multilineObj(obj: {
hello: "world",
x: 5
})
longWithObj(obj: { ,,longString: "hello world this is a very long string!", list: [1, 2, 3, 4, 5, 6, 7] })
emptyObj(arg: {})
}