GraphQL: Add support for printing operation names (#1992)
* Add support for printing GraphQL operation names * Remove extra empty line at the endmaster
parent
76c5733b55
commit
8cb259eac7
|
@ -20,10 +20,15 @@ function genericPrint(path, options, print) {
|
|||
|
||||
switch (n.kind) {
|
||||
case "Document": {
|
||||
return concat([join(hardline, path.map(print, "definitions")), hardline]);
|
||||
return join(concat([hardline, hardline]), path.map(print, "definitions"));
|
||||
}
|
||||
case "OperationDefinition": {
|
||||
return path.call(print, "selectionSet");
|
||||
return concat([
|
||||
n.name === null ? "" : concat([n.operation, " "]),
|
||||
path.call(print, "name"),
|
||||
n.name ? " " : "",
|
||||
path.call(print, "selectionSet")
|
||||
]);
|
||||
}
|
||||
case "SelectionSet": {
|
||||
return concat([
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`fields.graphql 1`] = `
|
||||
query MyFirstQuery {
|
||||
hello
|
||||
}
|
||||
|
||||
mutation
|
||||
MyFirstMutation {
|
||||
world
|
||||
}
|
||||
|
||||
subscription, ThisIsASub, {
|
||||
excellent
|
||||
}
|
||||
|
||||
, query, ThisIsASub, {
|
||||
excellent
|
||||
}
|
||||
|
||||
query {
|
||||
noName
|
||||
}
|
||||
|
||||
{
|
||||
noOperationType
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
query MyFirstQuery {
|
||||
hello
|
||||
}
|
||||
|
||||
mutation MyFirstMutation {
|
||||
world
|
||||
}
|
||||
|
||||
subscription ThisIsASub {
|
||||
excellent
|
||||
}
|
||||
|
||||
query ThisIsASub {
|
||||
excellent
|
||||
}
|
||||
|
||||
query {
|
||||
noName
|
||||
}
|
||||
|
||||
{
|
||||
noOperationType
|
||||
}
|
||||
`;
|
|
@ -0,0 +1,24 @@
|
|||
query MyFirstQuery {
|
||||
hello
|
||||
}
|
||||
|
||||
mutation
|
||||
MyFirstMutation {
|
||||
world
|
||||
}
|
||||
|
||||
subscription, ThisIsASub, {
|
||||
excellent
|
||||
}
|
||||
|
||||
, query, ThisIsASub, {
|
||||
excellent
|
||||
}
|
||||
|
||||
query {
|
||||
noName
|
||||
}
|
||||
|
||||
{
|
||||
noOperationType
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname, { parser: "graphql" });
|
|
@ -12,5 +12,4 @@ exports[`hello.graphql 1`] = `
|
|||
tagline
|
||||
}
|
||||
}
|
||||
|
||||
`;
|
||||
|
|
Loading…
Reference in New Issue