@@ -123,23 +123,19 @@ describe('Type System Printer', () => {
123123 fields : { str : { type : GraphQLString } } ,
124124 } ) ;
125125
126- const Root = new GraphQLObjectType ( {
127- name : 'Root ' ,
126+ const Query = new GraphQLObjectType ( {
127+ name : 'Query ' ,
128128 fields : { foo : { type : FooType } } ,
129129 } ) ;
130130
131- const Schema = new GraphQLSchema ( { query : Root } ) ;
131+ const Schema = new GraphQLSchema ( { query : Query } ) ;
132132 const output = printForTest ( Schema ) ;
133133 expect ( output ) . to . equal ( dedent `
134- schema {
135- query: Root
136- }
137-
138134 type Foo {
139135 str: String
140136 }
141137
142- type Root {
138+ type Query {
143139 foo: Foo
144140 }
145141 ` ) ;
@@ -270,6 +266,27 @@ describe('Type System Printer', () => {
270266 ` ) ;
271267 } ) ;
272268
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+
273290 it ( 'Print Interface' , ( ) => {
274291 const FooType = new GraphQLInterfaceType ( {
275292 name : 'Foo' ,
@@ -282,21 +299,17 @@ describe('Type System Printer', () => {
282299 interfaces : [ FooType ] ,
283300 } ) ;
284301
285- const Root = new GraphQLObjectType ( {
286- name : 'Root ' ,
302+ const Query = new GraphQLObjectType ( {
303+ name : 'Query ' ,
287304 fields : { bar : { type : BarType } } ,
288305 } ) ;
289306
290307 const Schema = new GraphQLSchema ( {
291- query : Root ,
308+ query : Query ,
292309 types : [ BarType ] ,
293310 } ) ;
294311 const output = printForTest ( Schema ) ;
295312 expect ( output ) . to . equal ( dedent `
296- schema {
297- query: Root
298- }
299-
300313 type Bar implements Foo {
301314 str: String
302315 }
@@ -305,7 +318,7 @@ describe('Type System Printer', () => {
305318 str: String
306319 }
307320
308- type Root {
321+ type Query {
309322 bar: Bar
310323 }
311324 ` ) ;
@@ -331,21 +344,17 @@ describe('Type System Printer', () => {
331344 interfaces : [ FooType , BaazType ] ,
332345 } ) ;
333346
334- const Root = new GraphQLObjectType ( {
335- name : 'Root ' ,
347+ const Query = new GraphQLObjectType ( {
348+ name : 'Query ' ,
336349 fields : { bar : { type : BarType } } ,
337350 } ) ;
338351
339352 const Schema = new GraphQLSchema ( {
340- query : Root ,
353+ query : Query ,
341354 types : [ BarType ] ,
342355 } ) ;
343356 const output = printForTest ( Schema ) ;
344357 expect ( output ) . to . equal ( dedent `
345- schema {
346- query: Root
347- }
348-
349358 interface Baaz {
350359 int: Int
351360 }
@@ -359,7 +368,7 @@ describe('Type System Printer', () => {
359368 str: String
360369 }
361370
362- type Root {
371+ type Query {
363372 bar: Bar
364373 }
365374 ` ) ;
@@ -390,21 +399,17 @@ describe('Type System Printer', () => {
390399 types : [ FooType , BarType ] ,
391400 } ) ;
392401
393- const Root = new GraphQLObjectType ( {
394- name : 'Root ' ,
402+ const Query = new GraphQLObjectType ( {
403+ name : 'Query ' ,
395404 fields : {
396405 single : { type : SingleUnion } ,
397406 multiple : { type : MultipleUnion } ,
398407 } ,
399408 } ) ;
400409
401- const Schema = new GraphQLSchema ( { query : Root } ) ;
410+ const Schema = new GraphQLSchema ( { query : Query } ) ;
402411 const output = printForTest ( Schema ) ;
403412 expect ( output ) . to . equal ( dedent `
404- schema {
405- query: Root
406- }
407-
408413 type Bar {
409414 str: String
410415 }
@@ -415,7 +420,7 @@ describe('Type System Printer', () => {
415420
416421 union MultipleUnion = Foo | Bar
417422
418- type Root {
423+ type Query {
419424 single: SingleUnion
420425 multiple: MultipleUnion
421426 }
@@ -432,8 +437,8 @@ describe('Type System Printer', () => {
432437 } ,
433438 } ) ;
434439
435- const Root = new GraphQLObjectType ( {
436- name : 'Root ' ,
440+ const Query = new GraphQLObjectType ( {
441+ name : 'Query ' ,
437442 fields : {
438443 str : {
439444 type : GraphQLString ,
@@ -442,18 +447,14 @@ describe('Type System Printer', () => {
442447 } ,
443448 } ) ;
444449
445- const Schema = new GraphQLSchema ( { query : Root } ) ;
450+ const Schema = new GraphQLSchema ( { query : Query } ) ;
446451 const output = printForTest ( Schema ) ;
447452 expect ( output ) . to . equal ( dedent `
448- schema {
449- query: Root
450- }
451-
452453 input InputType {
453454 int: Int
454455 }
455456
456- type Root {
457+ type Query {
457458 str(argOne: InputType): String
458459 }
459460 ` ) ;
@@ -467,23 +468,19 @@ describe('Type System Printer', () => {
467468 } ,
468469 } ) ;
469470
470- const Root = new GraphQLObjectType ( {
471- name : 'Root ' ,
471+ const Query = new GraphQLObjectType ( {
472+ name : 'Query ' ,
472473 fields : {
473474 odd : { type : OddType } ,
474475 } ,
475476 } ) ;
476477
477- const Schema = new GraphQLSchema ( { query : Root } ) ;
478+ const Schema = new GraphQLSchema ( { query : Query } ) ;
478479 const output = printForTest ( Schema ) ;
479480 expect ( output ) . to . equal ( dedent `
480- schema {
481- query: Root
482- }
483-
484481 scalar Odd
485482
486- type Root {
483+ type Query {
487484 odd: Odd
488485 }
489486 ` ) ;
@@ -499,29 +496,25 @@ describe('Type System Printer', () => {
499496 } ,
500497 } ) ;
501498
502- const Root = new GraphQLObjectType ( {
503- name : 'Root ' ,
499+ const Query = new GraphQLObjectType ( {
500+ name : 'Query ' ,
504501 fields : {
505502 rgb : { type : RGBType } ,
506503 } ,
507504 } ) ;
508505
509- const Schema = new GraphQLSchema ( { query : Root } ) ;
506+ const Schema = new GraphQLSchema ( { query : Query } ) ;
510507 const output = printForTest ( Schema ) ;
511508 expect ( output ) . to . equal ( dedent `
512- schema {
513- query: Root
509+ type Query {
510+ rgb: RGB
514511 }
515512
516513 enum RGB {
517514 RED
518515 GREEN
519516 BLUE
520517 }
521-
522- type Root {
523- rgb: RGB
524- }
525518 ` ) ;
526519 } ) ;
527520
@@ -553,19 +546,15 @@ describe('Type System Printer', () => {
553546 } ) ;
554547
555548 it ( 'Print Introspection Schema' , ( ) => {
556- const Root = new GraphQLObjectType ( {
557- name : 'Root ' ,
549+ const Query = new GraphQLObjectType ( {
550+ name : 'Query ' ,
558551 fields : {
559552 onlyField : { type : GraphQLString } ,
560553 } ,
561554 } ) ;
562- const Schema = new GraphQLSchema ( { query : Root } ) ;
555+ const Schema = new GraphQLSchema ( { query : Query } ) ;
563556 const output = printIntrospectionSchema ( Schema ) ;
564557 const introspectionSchema = dedent `
565- schema {
566- query: Root
567- }
568-
569558 """
570559 Directs the executor to include this field or fragment only when the \`if\` argument is true.
571560 """
@@ -796,21 +785,17 @@ describe('Type System Printer', () => {
796785 } ) ;
797786
798787 it ( 'Print Introspection Schema with comment descriptions' , ( ) => {
799- const Root = new GraphQLObjectType ( {
800- name : 'Root ' ,
788+ const Query = new GraphQLObjectType ( {
789+ name : 'Query ' ,
801790 fields : {
802791 onlyField : { type : GraphQLString } ,
803792 } ,
804793 } ) ;
805- const Schema = new GraphQLSchema ( { query : Root } ) ;
794+ const Schema = new GraphQLSchema ( { query : Query } ) ;
806795 const output = printIntrospectionSchema ( Schema , {
807796 commentDescriptions : true ,
808797 } ) ;
809798 const introspectionSchema = dedent `
810- schema {
811- query: Root
812- }
813-
814799 # Directs the executor to include this field or fragment only when the \`if\` argument is true.
815800 directive @include(
816801 # Included when true.
0 commit comments