@@ -123,23 +123,19 @@ describe('Type System Printer', () => {
123
123
fields : { str : { type : GraphQLString } } ,
124
124
} ) ;
125
125
126
- const Root = new GraphQLObjectType ( {
127
- name : 'Root ' ,
126
+ const Query = new GraphQLObjectType ( {
127
+ name : 'Query ' ,
128
128
fields : { foo : { type : FooType } } ,
129
129
} ) ;
130
130
131
- const Schema = new GraphQLSchema ( { query : Root } ) ;
131
+ const Schema = new GraphQLSchema ( { query : Query } ) ;
132
132
const output = printForTest ( Schema ) ;
133
133
expect ( output ) . to . equal ( dedent `
134
- schema {
135
- query: Root
136
- }
137
-
138
134
type Foo {
139
135
str: String
140
136
}
141
137
142
- type Root {
138
+ type Query {
143
139
foo: Foo
144
140
}
145
141
` ) ;
@@ -270,6 +266,27 @@ describe('Type System Printer', () => {
270
266
` ) ;
271
267
} ) ;
272
268
269
+ it ( 'Prints custom query root type' , ( ) => {
270
+ const CustomQueryType = new GraphQLObjectType ( {
271
+ name : 'CustomQueryType' ,
272
+ fields : { bar : { type : GraphQLString } } ,
273
+ } ) ;
274
+
275
+ const Schema = new GraphQLSchema ( {
276
+ query : CustomQueryType ,
277
+ } ) ;
278
+ const output = printForTest ( Schema ) ;
279
+ expect ( output ) . to . equal ( dedent `
280
+ schema {
281
+ query: CustomQueryType
282
+ }
283
+
284
+ type CustomQueryType {
285
+ bar: String
286
+ }
287
+ ` ) ;
288
+ } ) ;
289
+
273
290
it ( 'Print Interface' , ( ) => {
274
291
const FooType = new GraphQLInterfaceType ( {
275
292
name : 'Foo' ,
@@ -282,21 +299,17 @@ describe('Type System Printer', () => {
282
299
interfaces : [ FooType ] ,
283
300
} ) ;
284
301
285
- const Root = new GraphQLObjectType ( {
286
- name : 'Root ' ,
302
+ const Query = new GraphQLObjectType ( {
303
+ name : 'Query ' ,
287
304
fields : { bar : { type : BarType } } ,
288
305
} ) ;
289
306
290
307
const Schema = new GraphQLSchema ( {
291
- query : Root ,
308
+ query : Query ,
292
309
types : [ BarType ] ,
293
310
} ) ;
294
311
const output = printForTest ( Schema ) ;
295
312
expect ( output ) . to . equal ( dedent `
296
- schema {
297
- query: Root
298
- }
299
-
300
313
type Bar implements Foo {
301
314
str: String
302
315
}
@@ -305,7 +318,7 @@ describe('Type System Printer', () => {
305
318
str: String
306
319
}
307
320
308
- type Root {
321
+ type Query {
309
322
bar: Bar
310
323
}
311
324
` ) ;
@@ -331,21 +344,17 @@ describe('Type System Printer', () => {
331
344
interfaces : [ FooType , BaazType ] ,
332
345
} ) ;
333
346
334
- const Root = new GraphQLObjectType ( {
335
- name : 'Root ' ,
347
+ const Query = new GraphQLObjectType ( {
348
+ name : 'Query ' ,
336
349
fields : { bar : { type : BarType } } ,
337
350
} ) ;
338
351
339
352
const Schema = new GraphQLSchema ( {
340
- query : Root ,
353
+ query : Query ,
341
354
types : [ BarType ] ,
342
355
} ) ;
343
356
const output = printForTest ( Schema ) ;
344
357
expect ( output ) . to . equal ( dedent `
345
- schema {
346
- query: Root
347
- }
348
-
349
358
interface Baaz {
350
359
int: Int
351
360
}
@@ -359,7 +368,7 @@ describe('Type System Printer', () => {
359
368
str: String
360
369
}
361
370
362
- type Root {
371
+ type Query {
363
372
bar: Bar
364
373
}
365
374
` ) ;
@@ -390,21 +399,17 @@ describe('Type System Printer', () => {
390
399
types : [ FooType , BarType ] ,
391
400
} ) ;
392
401
393
- const Root = new GraphQLObjectType ( {
394
- name : 'Root ' ,
402
+ const Query = new GraphQLObjectType ( {
403
+ name : 'Query ' ,
395
404
fields : {
396
405
single : { type : SingleUnion } ,
397
406
multiple : { type : MultipleUnion } ,
398
407
} ,
399
408
} ) ;
400
409
401
- const Schema = new GraphQLSchema ( { query : Root } ) ;
410
+ const Schema = new GraphQLSchema ( { query : Query } ) ;
402
411
const output = printForTest ( Schema ) ;
403
412
expect ( output ) . to . equal ( dedent `
404
- schema {
405
- query: Root
406
- }
407
-
408
413
type Bar {
409
414
str: String
410
415
}
@@ -415,7 +420,7 @@ describe('Type System Printer', () => {
415
420
416
421
union MultipleUnion = Foo | Bar
417
422
418
- type Root {
423
+ type Query {
419
424
single: SingleUnion
420
425
multiple: MultipleUnion
421
426
}
@@ -432,8 +437,8 @@ describe('Type System Printer', () => {
432
437
} ,
433
438
} ) ;
434
439
435
- const Root = new GraphQLObjectType ( {
436
- name : 'Root ' ,
440
+ const Query = new GraphQLObjectType ( {
441
+ name : 'Query ' ,
437
442
fields : {
438
443
str : {
439
444
type : GraphQLString ,
@@ -442,18 +447,14 @@ describe('Type System Printer', () => {
442
447
} ,
443
448
} ) ;
444
449
445
- const Schema = new GraphQLSchema ( { query : Root } ) ;
450
+ const Schema = new GraphQLSchema ( { query : Query } ) ;
446
451
const output = printForTest ( Schema ) ;
447
452
expect ( output ) . to . equal ( dedent `
448
- schema {
449
- query: Root
450
- }
451
-
452
453
input InputType {
453
454
int: Int
454
455
}
455
456
456
- type Root {
457
+ type Query {
457
458
str(argOne: InputType): String
458
459
}
459
460
` ) ;
@@ -467,23 +468,19 @@ describe('Type System Printer', () => {
467
468
} ,
468
469
} ) ;
469
470
470
- const Root = new GraphQLObjectType ( {
471
- name : 'Root ' ,
471
+ const Query = new GraphQLObjectType ( {
472
+ name : 'Query ' ,
472
473
fields : {
473
474
odd : { type : OddType } ,
474
475
} ,
475
476
} ) ;
476
477
477
- const Schema = new GraphQLSchema ( { query : Root } ) ;
478
+ const Schema = new GraphQLSchema ( { query : Query } ) ;
478
479
const output = printForTest ( Schema ) ;
479
480
expect ( output ) . to . equal ( dedent `
480
- schema {
481
- query: Root
482
- }
483
-
484
481
scalar Odd
485
482
486
- type Root {
483
+ type Query {
487
484
odd: Odd
488
485
}
489
486
` ) ;
@@ -499,29 +496,25 @@ describe('Type System Printer', () => {
499
496
} ,
500
497
} ) ;
501
498
502
- const Root = new GraphQLObjectType ( {
503
- name : 'Root ' ,
499
+ const Query = new GraphQLObjectType ( {
500
+ name : 'Query ' ,
504
501
fields : {
505
502
rgb : { type : RGBType } ,
506
503
} ,
507
504
} ) ;
508
505
509
- const Schema = new GraphQLSchema ( { query : Root } ) ;
506
+ const Schema = new GraphQLSchema ( { query : Query } ) ;
510
507
const output = printForTest ( Schema ) ;
511
508
expect ( output ) . to . equal ( dedent `
512
- schema {
513
- query: Root
509
+ type Query {
510
+ rgb: RGB
514
511
}
515
512
516
513
enum RGB {
517
514
RED
518
515
GREEN
519
516
BLUE
520
517
}
521
-
522
- type Root {
523
- rgb: RGB
524
- }
525
518
` ) ;
526
519
} ) ;
527
520
@@ -553,19 +546,15 @@ describe('Type System Printer', () => {
553
546
} ) ;
554
547
555
548
it ( 'Print Introspection Schema' , ( ) => {
556
- const Root = new GraphQLObjectType ( {
557
- name : 'Root ' ,
549
+ const Query = new GraphQLObjectType ( {
550
+ name : 'Query ' ,
558
551
fields : {
559
552
onlyField : { type : GraphQLString } ,
560
553
} ,
561
554
} ) ;
562
- const Schema = new GraphQLSchema ( { query : Root } ) ;
555
+ const Schema = new GraphQLSchema ( { query : Query } ) ;
563
556
const output = printIntrospectionSchema ( Schema ) ;
564
557
const introspectionSchema = dedent `
565
- schema {
566
- query: Root
567
- }
568
-
569
558
"""
570
559
Directs the executor to include this field or fragment only when the \`if\` argument is true.
571
560
"""
@@ -796,21 +785,17 @@ describe('Type System Printer', () => {
796
785
} ) ;
797
786
798
787
it ( 'Print Introspection Schema with comment descriptions' , ( ) => {
799
- const Root = new GraphQLObjectType ( {
800
- name : 'Root ' ,
788
+ const Query = new GraphQLObjectType ( {
789
+ name : 'Query ' ,
801
790
fields : {
802
791
onlyField : { type : GraphQLString } ,
803
792
} ,
804
793
} ) ;
805
- const Schema = new GraphQLSchema ( { query : Root } ) ;
794
+ const Schema = new GraphQLSchema ( { query : Query } ) ;
806
795
const output = printIntrospectionSchema ( Schema , {
807
796
commentDescriptions : true ,
808
797
} ) ;
809
798
const introspectionSchema = dedent `
810
- schema {
811
- query: Root
812
- }
813
-
814
799
# Directs the executor to include this field or fragment only when the \`if\` argument is true.
815
800
directive @include(
816
801
# Included when true.
0 commit comments