Skip to content

Commit 5ccf579

Browse files
print: add spaces inside input object (#3456)
1 parent 4498014 commit 5ccf579

File tree

8 files changed

+22
-20
lines changed

8 files changed

+22
-20
lines changed

src/language/__tests__/printer-test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ describe('Printer: Query document', () => {
6666

6767
it('prints query with variable directives', () => {
6868
const queryASTWithVariableDirective = parse(
69-
'query ($foo: TestType = {a: 123} @testDirective(if: true) @test) { id }',
69+
'query ($foo: TestType = { a: 123 } @testDirective(if: true) @test) { id }',
7070
);
7171
expect(print(queryASTWithVariableDirective)).to.equal(dedent`
72-
query ($foo: TestType = {a: 123} @testDirective(if: true) @test) {
72+
query ($foo: TestType = { a: 123 } @testDirective(if: true) @test) {
7373
id
7474
}
7575
`);
@@ -196,9 +196,9 @@ describe('Printer: Query document', () => {
196196
foo(
197197
size: $size
198198
bar: $b
199-
obj: {key: "value", block: """
199+
obj: { key: "value", block: """
200200
block string uses \"""
201-
"""}
201+
""" }
202202
)
203203
}
204204

src/language/__tests__/schema-printer-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('Printer: SDL document', () => {
5959
three(argument: InputType, other: String): Int
6060
four(argument: String = "string"): String
6161
five(argument: [String] = ["string", "string"]): String
62-
six(argument: InputType = {key: "value"}): Type
62+
six(argument: InputType = { key: "value" }): Type
6363
seven(argument: Int = null): Type
6464
}
6565

src/language/printer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const printDocASTReducer: ASTReducer<string> = {
116116
NullValue: { leave: () => 'null' },
117117
EnumValue: { leave: ({ value }) => value },
118118
ListValue: { leave: ({ values }) => '[' + join(values, ', ') + ']' },
119-
ObjectValue: { leave: ({ fields }) => '{' + join(fields, ', ') + '}' },
119+
ObjectValue: { leave: ({ fields }) => '{ ' + join(fields, ', ') + ' }' },
120120
ObjectField: { leave: ({ name, value }) => name + ': ' + value },
121121

122122
// Directive

src/type/__tests__/introspection-test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ describe('Introspection', () => {
10861086
const schema = buildSchema(`
10871087
input InputObjectWithDefaultValues {
10881088
a: String = "Emoji: \\u{1F600}"
1089-
b: Complex = {x: ["abc"], y: 123}
1089+
b: Complex = { x: ["abc"], y: 123 }
10901090
}
10911091
10921092
input Complex {
@@ -1120,7 +1120,7 @@ describe('Introspection', () => {
11201120
},
11211121
{
11221122
name: 'b',
1123-
defaultValue: '{x: ["abc"], y: 123}',
1123+
defaultValue: '{ x: ["abc"], y: 123 }',
11241124
},
11251125
],
11261126
},

src/type/__tests__/scalars-test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('Type System: Specified scalar types', () => {
9999
'Int cannot represent non-integer value: [1]',
100100
);
101101
expect(() => parseLiteral('{ value: 1 }')).to.throw(
102-
'Int cannot represent non-integer value: {value: 1}',
102+
'Int cannot represent non-integer value: { value: 1 }',
103103
);
104104
expect(() => parseLiteral('ENUM_VALUE')).to.throw(
105105
'Int cannot represent non-integer value: ENUM_VALUE',
@@ -259,7 +259,7 @@ describe('Type System: Specified scalar types', () => {
259259
'Float cannot represent non numeric value: [0.1]',
260260
);
261261
expect(() => parseLiteral('{ value: 0.1 }')).to.throw(
262-
'Float cannot represent non numeric value: {value: 0.1}',
262+
'Float cannot represent non numeric value: { value: 0.1 }',
263263
);
264264
expect(() => parseLiteral('ENUM_VALUE')).to.throw(
265265
'Float cannot represent non numeric value: ENUM_VALUE',
@@ -366,7 +366,7 @@ describe('Type System: Specified scalar types', () => {
366366
'String cannot represent a non string value: ["foo"]',
367367
);
368368
expect(() => parseLiteral('{ value: "foo" }')).to.throw(
369-
'String cannot represent a non string value: {value: "foo"}',
369+
'String cannot represent a non string value: { value: "foo" }',
370370
);
371371
expect(() => parseLiteral('ENUM_VALUE')).to.throw(
372372
'String cannot represent a non string value: ENUM_VALUE',
@@ -484,7 +484,7 @@ describe('Type System: Specified scalar types', () => {
484484
'Boolean cannot represent a non boolean value: [false]',
485485
);
486486
expect(() => parseLiteral('{ value: false }')).to.throw(
487-
'Boolean cannot represent a non boolean value: {value: false}',
487+
'Boolean cannot represent a non boolean value: { value: false }',
488488
);
489489
expect(() => parseLiteral('ENUM_VALUE')).to.throw(
490490
'Boolean cannot represent a non boolean value: ENUM_VALUE',
@@ -599,7 +599,7 @@ describe('Type System: Specified scalar types', () => {
599599
'ID cannot represent a non-string and non-integer value: ["1"]',
600600
);
601601
expect(() => parseLiteral('{ value: "1" }')).to.throw(
602-
'ID cannot represent a non-string and non-integer value: {value: "1"}',
602+
'ID cannot represent a non-string and non-integer value: { value: "1" }',
603603
);
604604
expect(() => parseLiteral('ENUM_VALUE')).to.throw(
605605
'ID cannot represent a non-string and non-integer value: ENUM_VALUE',

src/utilities/__tests__/buildClientSchema-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ describe('Type System: build schema from introspection', () => {
443443
type Query {
444444
defaultInt(intArg: Int = 30): String
445445
defaultList(listArg: [Int] = [1, 2, 3]): String
446-
defaultObject(objArg: Geo = {lat: 37.485, lon: -122.148}): String
446+
defaultObject(objArg: Geo = { lat: 37.485, lon: -122.148 }): String
447447
defaultNull(intArg: Int = null): String
448448
noDefault(intArg: Int): String
449449
}

src/utilities/__tests__/findBreakingChanges-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ describe('findDangerousChanges', () => {
961961
{
962962
type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,
963963
description:
964-
'Type1.field1 arg complexObject has changed defaultValue from {innerInputArray: [{arrayField: [1, 2, 3]}]} to {innerInputArray: [{arrayField: [3, 2, 1]}]}.',
964+
'Type1.field1 arg complexObject has changed defaultValue from { innerInputArray: [{ arrayField: [1, 2, 3] }] } to { innerInputArray: [{ arrayField: [3, 2, 1] }] }.',
965965
},
966966
]);
967967
});

src/utilities/__tests__/sortValueNode-test.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ describe('sortValueNode', () => {
2828
});
2929

3030
it('sort input object fields', () => {
31-
expectSortedValue('{ b: 2, a: 1 }').to.equal('{a: 1, b: 2}');
32-
expectSortedValue('{ a: { c: 3, b: 2 } }').to.equal('{a: {b: 2, c: 3}}');
33-
expectSortedValue('[{ b: 2, a: 1 }, { d: 4, c: 3}]').to.equal(
34-
'[{a: 1, b: 2}, {c: 3, d: 4}]',
31+
expectSortedValue('{ b: 2, a: 1 }').to.equal('{ a: 1, b: 2 }');
32+
expectSortedValue('{ a: { c: 3, b: 2 } }').to.equal(
33+
'{ a: { b: 2, c: 3 } }',
34+
);
35+
expectSortedValue('[{ b: 2, a: 1 }, { d: 4, c: 3 }]').to.equal(
36+
'[{ a: 1, b: 2 }, { c: 3, d: 4 }]',
3537
);
3638
expectSortedValue(
3739
'{ b: { g: 7, f: 6 }, c: 3 , a: { d: 4, e: 5 } }',
38-
).to.equal('{a: {d: 4, e: 5}, b: {f: 6, g: 7}, c: 3}');
40+
).to.equal('{ a: { d: 4, e: 5 }, b: { f: 6, g: 7 }, c: 3 }');
3941
});
4042
});

0 commit comments

Comments
 (0)