Add support for GraphQL object values (#2010)
parent
c441f87fc0
commit
7c051804a8
|
@ -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"),
|
||||
|
|
|
@ -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: {})
|
||||
}
|
||||
`;
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname, { parser: "graphql" });
|
|
@ -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: {})
|
||||
}
|
Loading…
Reference in New Issue