Skip to content

Commit ff4338d

Browse files
authored
Fix rearranged schema printing (#920)
* Revert "Sort fields before printing to get a more stable diff" This reverts commit 3d8faca. * Revert "update tests" This reverts commit e0fb703.
1 parent 6a85e88 commit ff4338d

File tree

4 files changed

+75
-77
lines changed

4 files changed

+75
-77
lines changed

src/utilities/__tests__/buildASTSchema-test.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ describe('Schema Builder', () => {
6969
}
7070
7171
type HelloScalars {
72-
bool: Boolean
72+
str: String
73+
int: Int
7374
float: Float
7475
id: ID
75-
int: Int
76-
str: String
76+
bool: Boolean
7777
}
78-
`;
78+
`;
79+
7980
const output = cycleOutput(body);
8081
expect(output).to.equal(body);
8182
});
@@ -197,11 +198,11 @@ describe('Schema Builder', () => {
197198
}
198199
199200
type HelloScalars {
200-
listOfNonNullStrs: [String!]
201+
nonNullStr: String!
201202
listOfStrs: [String]
202-
nonNullListOfNonNullStrs: [String!]!
203+
listOfNonNullStrs: [String!]
203204
nonNullListOfStrs: [String]!
204-
nonNullStr: String!
205+
nonNullListOfNonNullStrs: [String!]!
205206
}
206207
`;
207208
const output = cycleOutput(body);
@@ -216,8 +217,8 @@ describe('Schema Builder', () => {
216217
}
217218
218219
type Recurse {
219-
recurse: Recurse
220220
str: String
221+
recurse: Recurse
221222
}
222223
`;
223224
const output = cycleOutput(body);
@@ -251,10 +252,10 @@ describe('Schema Builder', () => {
251252
}
252253
253254
type Hello {
254-
booleanToStr(bool: Boolean): String
255+
str(int: Int): String
255256
floatToStr(float: Float): String
256257
idToStr(id: ID): String
257-
str(int: Int): String
258+
booleanToStr(bool: Boolean): String
258259
strToStr(bool: String): String
259260
}
260261
`;
@@ -451,9 +452,9 @@ describe('Schema Builder', () => {
451452
}
452453
453454
type HelloScalars {
454-
bool: Boolean
455-
int: Int
456455
str: String
456+
int: Int
457+
bool: Boolean
457458
}
458459
459460
type Mutation {
@@ -472,9 +473,9 @@ describe('Schema Builder', () => {
472473
}
473474
474475
type HelloScalars {
475-
bool: Boolean
476-
int: Int
477476
str: String
477+
int: Int
478+
bool: Boolean
478479
}
479480
480481
type Subscription {
@@ -528,9 +529,9 @@ describe('Schema Builder', () => {
528529
}
529530
530531
type Query {
531-
enum: MyEnum
532532
field1: String @deprecated
533533
field2: Int @deprecated(reason: "Because I said so")
534+
enum: MyEnum
534535
}
535536
`;
536537
const output = cycleOutput(body);

src/utilities/__tests__/extendSchema-test.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ describe('extendSchema', () => {
159159
expect(printSchema(testSchema)).to.equal(originalPrint);
160160
expect(printSchema(extendedSchema)).to.equal(dedent`
161161
type Bar implements SomeInterface {
162-
foo: Foo
163162
name: String
164163
some: SomeInterface
164+
foo: Foo
165165
}
166166
167167
type Biz {
@@ -170,16 +170,16 @@ describe('extendSchema', () => {
170170
171171
type Foo implements SomeInterface {
172172
name: String
173-
newField: String
174173
some: SomeInterface
175174
tree: [Foo]!
175+
newField: String
176176
}
177177
178178
type Query {
179179
foo: Foo
180+
someUnion: SomeUnion
180181
someEnum: SomeEnum
181182
someInterface(id: ID!): SomeInterface
182-
someUnion: SomeUnion
183183
}
184184
185185
enum SomeEnum {
@@ -252,9 +252,9 @@ describe('extendSchema', () => {
252252
expect(printSchema(testSchema)).to.equal(originalPrint);
253253
expect(printSchema(extendedSchema)).to.equal(dedent`
254254
type Bar implements SomeInterface {
255-
foo: Foo
256255
name: String
257256
some: SomeInterface
257+
foo: Foo
258258
}
259259
260260
type Biz {
@@ -269,9 +269,9 @@ describe('extendSchema', () => {
269269
270270
type Query {
271271
foo: Foo
272+
someUnion: SomeUnion
272273
someEnum: SomeEnum
273274
someInterface(id: ID!): SomeInterface
274-
someUnion: SomeUnion
275275
}
276276
277277
enum SomeEnum {
@@ -310,9 +310,9 @@ describe('extendSchema', () => {
310310
expect(printSchema(testSchema)).to.equal(originalPrint);
311311
expect(printSchema(extendedSchema)).to.equal(dedent`
312312
type Bar implements SomeInterface {
313-
foo: Foo
314313
name: String
315314
some: SomeInterface
315+
foo: Foo
316316
}
317317
318318
type Biz {
@@ -321,9 +321,9 @@ describe('extendSchema', () => {
321321
322322
type Foo implements SomeInterface {
323323
name: String
324-
newField(arg1: String, arg2: NewInputObj!): String
325324
some: SomeInterface
326325
tree: [Foo]!
326+
newField(arg1: String, arg2: NewInputObj!): String
327327
}
328328
329329
input NewInputObj {
@@ -334,9 +334,9 @@ describe('extendSchema', () => {
334334
335335
type Query {
336336
foo: Foo
337+
someUnion: SomeUnion
337338
someEnum: SomeEnum
338339
someInterface(id: ID!): SomeInterface
339-
someUnion: SomeUnion
340340
}
341341
342342
enum SomeEnum {
@@ -365,9 +365,9 @@ describe('extendSchema', () => {
365365
expect(printSchema(testSchema)).to.equal(originalPrint);
366366
expect(printSchema(extendedSchema)).to.equal(dedent`
367367
type Bar implements SomeInterface {
368-
foo: Foo
369368
name: String
370369
some: SomeInterface
370+
foo: Foo
371371
}
372372
373373
type Biz {
@@ -376,16 +376,16 @@ describe('extendSchema', () => {
376376
377377
type Foo implements SomeInterface {
378378
name: String
379-
newField(arg1: SomeEnum!): SomeEnum
380379
some: SomeInterface
381380
tree: [Foo]!
381+
newField(arg1: SomeEnum!): SomeEnum
382382
}
383383
384384
type Query {
385385
foo: Foo
386+
someUnion: SomeUnion
386387
someEnum: SomeEnum
387388
someInterface(id: ID!): SomeInterface
388-
someUnion: SomeUnion
389389
}
390390
391391
enum SomeEnum {
@@ -415,9 +415,9 @@ describe('extendSchema', () => {
415415
expect(printSchema(testSchema)).to.equal(originalPrint);
416416
expect(printSchema(extendedSchema)).to.equal(dedent`
417417
type Bar implements SomeInterface {
418-
foo: Foo
419418
name: String
420419
some: SomeInterface
420+
foo: Foo
421421
}
422422
423423
type Biz implements SomeInterface {
@@ -434,9 +434,9 @@ describe('extendSchema', () => {
434434
435435
type Query {
436436
foo: Foo
437+
someUnion: SomeUnion
437438
someEnum: SomeEnum
438439
someInterface(id: ID!): SomeInterface
439-
someUnion: SomeUnion
440440
}
441441
442442
enum SomeEnum {
@@ -491,9 +491,9 @@ describe('extendSchema', () => {
491491
expect(printSchema(testSchema)).to.equal(originalPrint);
492492
expect(printSchema(extendedSchema)).to.equal(dedent`
493493
type Bar implements SomeInterface {
494-
foo: Foo
495494
name: String
496495
some: SomeInterface
496+
foo: Foo
497497
}
498498
499499
type Biz {
@@ -502,14 +502,14 @@ describe('extendSchema', () => {
502502
503503
type Foo implements SomeInterface {
504504
name: String
505-
newEnum: NewEnum
506-
newInterface: NewInterface
505+
some: SomeInterface
506+
tree: [Foo]!
507507
newObject: NewObject
508+
newInterface: NewInterface
509+
newUnion: NewUnion
508510
newScalar: NewScalar
511+
newEnum: NewEnum
509512
newTree: [Foo]!
510-
newUnion: NewUnion
511-
some: SomeInterface
512-
tree: [Foo]!
513513
}
514514
515515
enum NewEnum {
@@ -535,9 +535,9 @@ describe('extendSchema', () => {
535535
536536
type Query {
537537
foo: Foo
538+
someUnion: SomeUnion
538539
someEnum: SomeEnum
539540
someInterface(id: ID!): SomeInterface
540-
someUnion: SomeUnion
541541
}
542542
543543
enum SomeEnum {
@@ -570,20 +570,20 @@ describe('extendSchema', () => {
570570
expect(printSchema(testSchema)).to.equal(originalPrint);
571571
expect(printSchema(extendedSchema)).to.equal(dedent`
572572
type Bar implements SomeInterface {
573-
foo: Foo
574573
name: String
575574
some: SomeInterface
575+
foo: Foo
576576
}
577577
578578
type Biz {
579579
fizz: String
580580
}
581581
582582
type Foo implements SomeInterface, NewInterface {
583-
baz: String
584583
name: String
585584
some: SomeInterface
586585
tree: [Foo]!
586+
baz: String
587587
}
588588
589589
interface NewInterface {
@@ -592,9 +592,9 @@ describe('extendSchema', () => {
592592
593593
type Query {
594594
foo: Foo
595+
someUnion: SomeUnion
595596
someEnum: SomeEnum
596597
someInterface(id: ID!): SomeInterface
597-
someUnion: SomeUnion
598598
}
599599
600600
enum SomeEnum {
@@ -638,18 +638,18 @@ describe('extendSchema', () => {
638638
expect(printSchema(testSchema)).to.equal(originalPrint);
639639
expect(printSchema(extendedSchema)).to.equal(dedent`
640640
type Bar implements SomeInterface {
641-
foo: Foo
642641
name: String
643642
some: SomeInterface
643+
foo: Foo
644644
}
645645
646646
type Biz implements NewInterface, SomeInterface {
647-
buzz: String
648647
fizz: String
648+
buzz: String
649649
name: String
650+
some: SomeInterface
650651
newFieldA: Int
651652
newFieldB: Float
652-
some: SomeInterface
653653
}
654654
655655
type Foo implements SomeInterface {
@@ -664,9 +664,9 @@ describe('extendSchema', () => {
664664
665665
type Query {
666666
foo: Foo
667+
someUnion: SomeUnion
667668
someEnum: SomeEnum
668669
someInterface(id: ID!): SomeInterface
669-
someUnion: SomeUnion
670670
}
671671
672672
enum SomeEnum {
@@ -729,13 +729,13 @@ describe('extendSchema', () => {
729729
}
730730
731731
type Query {
732-
newQueryField: Int
733732
queryField: String
733+
newQueryField: Int
734734
}
735735
736736
type Subscription {
737-
newSubscriptionField: Int
738737
subscriptionField: String
738+
newSubscriptionField: Int
739739
}
740740
`);
741741
});

0 commit comments

Comments
 (0)