diff --git a/src/printer-graphql.js b/src/printer-graphql.js index b5c2914de..503d378a5 100644 --- a/src/printer-graphql.js +++ b/src/printer-graphql.js @@ -143,7 +143,7 @@ function genericPrint(path, options, print) { return group( concat([ "{", - n.fields.length > 0 ? " " : "", + options.bracketSpacing && n.fields.length > 0 ? " " : "", indent( concat([ softline, @@ -154,7 +154,7 @@ function genericPrint(path, options, print) { ]) ), softline, - ifBreak("", n.fields.length > 0 ? " " : ""), + ifBreak("", options.bracketSpacing && n.fields.length > 0 ? " " : ""), "}" ]) ); diff --git a/tests/graphql_bracket_spacing/__snapshots__/jsfmt.spec.js.snap b/tests/graphql_bracket_spacing/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..143ab37d7 --- /dev/null +++ b/tests/graphql_bracket_spacing/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,29 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`bracket_spacing.graphql 1`] = ` +fragment Visit on HighlightedVisit + @argumentDefinitions( + count: {type: "Int", defaultValue: 20} + ) { + name +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +fragment Visit on HighlightedVisit + @argumentDefinitions(count: { type: "Int", defaultValue: 20 }) { + name +} +`; + +exports[`bracket_spacing.graphql 2`] = ` +fragment Visit on HighlightedVisit + @argumentDefinitions( + count: {type: "Int", defaultValue: 20} + ) { + name +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +fragment Visit on HighlightedVisit + @argumentDefinitions(count: {type: "Int", defaultValue: 20}) { + name +} +`; diff --git a/tests/graphql_bracket_spacing/bracket_spacing.graphql b/tests/graphql_bracket_spacing/bracket_spacing.graphql new file mode 100644 index 000000000..0e047c3f5 --- /dev/null +++ b/tests/graphql_bracket_spacing/bracket_spacing.graphql @@ -0,0 +1,6 @@ +fragment Visit on HighlightedVisit + @argumentDefinitions( + count: {type: "Int", defaultValue: 20} + ) { + name +} diff --git a/tests/graphql_bracket_spacing/jsfmt.spec.js b/tests/graphql_bracket_spacing/jsfmt.spec.js new file mode 100644 index 000000000..4f10d724b --- /dev/null +++ b/tests/graphql_bracket_spacing/jsfmt.spec.js @@ -0,0 +1,2 @@ +run_spec(__dirname, { parser: "graphql" }); +run_spec(__dirname, { parser: "graphql", bracketSpacing: false });