Don't add new lines after unless present in graphql (#4512)
* Don't add new lines after unless present in graphql * fix logic and add more specs * use index
This commit is contained in:
1 parent
938d2f06be
commit
31f79fbc22
3 files changed
+43
-10
No files matched your search
@@ -24,10 +24,22 @@ function genericPrint(path, options, print) {
|
||||
|
||||
switch (n.kind) {
|
||||
case "Document": {
|
||||
return concat([
|
||||
join(concat([hardline, hardline]), path.map(print, "definitions")),
|
||||
hardline
|
||||
]);
|
||||
const parts = [];
|
||||
path.map((pathChild, index) => {
|
||||
parts.push(concat([pathChild.call(print)]));
|
||||
parts.push(hardline);
|
||||
if (
|
||||
index !== n.definitions.length - 1 &&
|
||||
sharedUtil.isNextLineEmpty(
|
||||
options.originalText,
|
||||
pathChild.getValue(),
|
||||
options
|
||||
)
|
||||
) {
|
||||
parts.push(hardline);
|
||||
}
|
||||
}, "definitions");
|
||||
return concat(parts, hardline);
|
||||
}
|
||||
case "OperationDefinition": {
|
||||
const hasOperation = options.originalText[options.locStart(n)] !== "{";
|
||||
|
||||
@@ -7,17 +7,28 @@ directive @a(as: String = 1) on QUERY
|
||||
directive @a(as: String, b: Int!) on QUERY
|
||||
directive @a(as: String! = 1 @deprecated) on QUERY
|
||||
directive @a(as: String! = 1 @deprecated) on QUERY | MUTATION
|
||||
|
||||
directive @a on QUERY
|
||||
|
||||
|
||||
directive @a(as: String) on QUERY
|
||||
|
||||
|
||||
|
||||
|
||||
directive @a(as: String = 1) on QUERY
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
directive @a on QUERY
|
||||
directive @a(as: String) on QUERY
|
||||
directive @a(as: String = 1) on QUERY
|
||||
directive @a(as: String, b: Int!) on QUERY
|
||||
directive @a(as: String! = 1 @deprecated) on QUERY
|
||||
directive @a(as: String! = 1 @deprecated) on QUERY | MUTATION
|
||||
|
||||
directive @a on QUERY
|
||||
|
||||
directive @a(as: String) on QUERY
|
||||
|
||||
directive @a(as: String = 1) on QUERY
|
||||
|
||||
directive @a(as: String, b: Int!) on QUERY
|
||||
|
||||
directive @a(as: String! = 1 @deprecated) on QUERY
|
||||
|
||||
directive @a(as: String! = 1 @deprecated) on QUERY | MUTATION
|
||||
|
||||
`;
|
||||
@@ -4,3 +4,13 @@ directive @a(as: String = 1) on QUERY
|
||||
directive @a(as: String, b: Int!) on QUERY
|
||||
directive @a(as: String! = 1 @deprecated) on QUERY
|
||||
directive @a(as: String! = 1 @deprecated) on QUERY | MUTATION
|
||||
|
||||
directive @a on QUERY
|
||||
|
||||
|
||||
directive @a(as: String) on QUERY
|
||||
|
||||
|
||||
|
||||
|
||||
directive @a(as: String = 1) on QUERY
|
||||
Reference in new issue
Block a user