@@ -474,10 +474,10 @@ describe('Field config must be object', () => {
474
474
} ) ;
475
475
476
476
it ( 'rejects an Object type field with undefined config' , ( ) => {
477
- // $DisableFlowOnNegativeTest
478
477
const objType = new GraphQLObjectType ( {
479
478
name : 'SomeObject' ,
480
479
fields : {
480
+ // $DisableFlowOnNegativeTest
481
481
f : undefined ,
482
482
} ,
483
483
} ) ;
@@ -487,9 +487,9 @@ describe('Field config must be object', () => {
487
487
} ) ;
488
488
489
489
it ( 'rejects an Object type with incorrectly typed fields' , ( ) => {
490
- // $DisableFlowOnNegativeTest
491
490
const objType = new GraphQLObjectType ( {
492
491
name : 'SomeObject' ,
492
+ // $DisableFlowOnNegativeTest
493
493
fields : [ { field : GraphQLString } ] ,
494
494
} ) ;
495
495
expect ( ( ) => objType . getFields ( ) ) . to . throw (
@@ -499,10 +499,10 @@ describe('Field config must be object', () => {
499
499
} ) ;
500
500
501
501
it ( 'rejects an Object type with a field function that returns incorrect type' , ( ) => {
502
- // $DisableFlowOnNegativeTest
503
502
const objType = new GraphQLObjectType ( {
504
503
name : 'SomeObject' ,
505
504
fields ( ) {
505
+ // $DisableFlowOnNegativeTest
506
506
return [ { field : GraphQLString } ] ;
507
507
} ,
508
508
} ) ;
@@ -530,12 +530,12 @@ describe('Field arg config must be object', () => {
530
530
} ) ;
531
531
532
532
it ( 'rejects an Object type with incorrectly typed field args' , ( ) => {
533
- // $DisableFlowOnNegativeTest
534
533
const objType = new GraphQLObjectType ( {
535
534
name : 'SomeObject' ,
536
535
fields : {
537
536
badField : {
538
537
type : GraphQLString ,
538
+ // $DisableFlowOnNegativeTest
539
539
args : [ { badArg : GraphQLString } ] ,
540
540
} ,
541
541
} ,
@@ -547,14 +547,11 @@ describe('Field arg config must be object', () => {
547
547
548
548
it ( 'does not allow isDeprecated instead of deprecationReason on field' , ( ) => {
549
549
expect ( ( ) => {
550
- // $DisableFlowOnNegativeTest
551
550
const OldObject = new GraphQLObjectType ( {
552
551
name : 'OldObject' ,
553
552
fields : {
554
- field : {
555
- type : GraphQLString ,
556
- isDeprecated : true ,
557
- } ,
553
+ // $DisableFlowOnNegativeTest
554
+ field : { type : GraphQLString , isDeprecated : true } ,
558
555
} ,
559
556
} ) ;
560
557
@@ -586,25 +583,25 @@ describe('Object interfaces must be array', () => {
586
583
} ) ;
587
584
588
585
it ( 'rejects an Object type with incorrectly typed interfaces' , ( ) => {
589
- // $DisableFlowOnNegativeTest
590
586
const objType = new GraphQLObjectType ( {
591
587
name : 'SomeObject' ,
588
+ fields : { } ,
589
+ // $DisableFlowOnNegativeTest
592
590
interfaces : { } ,
593
- fields : { f : { type : GraphQLString } } ,
594
591
} ) ;
595
592
expect ( ( ) => objType . getInterfaces ( ) ) . to . throw (
596
593
'SomeObject interfaces must be an Array or a function which returns an Array.' ,
597
594
) ;
598
595
} ) ;
599
596
600
597
it ( 'rejects an Object type with interfaces as a function returning an incorrect type' , ( ) => {
601
- // $DisableFlowOnNegativeTest
602
598
const objType = new GraphQLObjectType ( {
603
599
name : 'SomeObject' ,
600
+ fields : { } ,
601
+ // $DisableFlowOnNegativeTest
604
602
interfaces ( ) {
605
603
return { } ;
606
604
} ,
607
- fields : { f : { type : GraphQLString } } ,
608
605
} ) ;
609
606
expect ( ( ) => objType . getInterfaces ( ) ) . to . throw (
610
607
'SomeObject interfaces must be an Array or a function which returns an Array.' ,
@@ -712,11 +709,11 @@ describe('Type System: Interface types must be resolvable', () => {
712
709
it ( 'rejects an Interface type with an incorrect type for resolveType' , ( ) => {
713
710
expect (
714
711
( ) =>
715
- // $DisableFlowOnNegativeTest
716
712
new GraphQLInterfaceType ( {
717
713
name : 'AnotherInterface' ,
714
+ fields : { } ,
715
+ // $DisableFlowOnNegativeTest
718
716
resolveType : { } ,
719
- fields : { f : { type : GraphQLString } } ,
720
717
} ) ,
721
718
) . to . throw (
722
719
'AnotherInterface must provide "resolveType" as a function, but got: {}.' ,
@@ -766,11 +763,11 @@ describe('Type System: Union types must be resolvable', () => {
766
763
it ( 'rejects an Interface type with an incorrect type for resolveType' , ( ) => {
767
764
expect ( ( ) =>
768
765
schemaWithFieldType (
769
- // $DisableFlowOnNegativeTest
770
766
new GraphQLUnionType ( {
771
767
name : 'SomeUnion' ,
768
+ types : [ ] ,
769
+ // $DisableFlowOnNegativeTest
772
770
resolveType : { } ,
773
- types : [ ObjectWithIsTypeOf ] ,
774
771
} ) ,
775
772
) ,
776
773
) . to . throw (
@@ -792,7 +789,6 @@ describe('Type System: Scalar types must be serializable', () => {
792
789
} ) ;
793
790
794
791
it ( 'rejects a Scalar type not defining serialize' , ( ) => {
795
- // $DisableFlowOnNegativeTest
796
792
expect ( ( ) =>
797
793
schemaWithFieldType (
798
794
// $DisableFlowOnNegativeTest
@@ -808,12 +804,11 @@ describe('Type System: Scalar types must be serializable', () => {
808
804
} ) ;
809
805
810
806
it ( 'rejects a Scalar type defining serialize with an incorrect type' , ( ) => {
811
- // $DisableFlowOnNegativeTest
812
807
expect ( ( ) =>
813
808
schemaWithFieldType (
814
- // $DisableFlowOnNegativeTest
815
809
new GraphQLScalarType ( {
816
810
name : 'SomeScalar' ,
811
+ // $DisableFlowOnNegativeTest
817
812
serialize : { } ,
818
813
} ) ,
819
814
) ,
@@ -868,11 +863,12 @@ describe('Type System: Scalar types must be serializable', () => {
868
863
it ( 'rejects a Scalar type defining parseValue and parseLiteral with an incorrect type' , ( ) => {
869
864
expect ( ( ) =>
870
865
schemaWithFieldType (
871
- // $DisableFlowOnNegativeTest
872
866
new GraphQLScalarType ( {
873
867
name : 'SomeScalar' ,
874
868
serialize : ( ) => null ,
869
+ // $DisableFlowOnNegativeTest
875
870
parseValue : { } ,
871
+ // $DisableFlowOnNegativeTest
876
872
parseLiteral : { } ,
877
873
} ) ,
878
874
) ,
@@ -897,11 +893,11 @@ describe('Type System: Object types must be assertable', () => {
897
893
it ( 'rejects an Object type with an incorrect type for isTypeOf' , ( ) => {
898
894
expect ( ( ) => {
899
895
schemaWithFieldType (
900
- // $DisableFlowOnNegativeTest
901
896
new GraphQLObjectType ( {
902
897
name : 'AnotherObject' ,
898
+ fields : { } ,
899
+ // $DisableFlowOnNegativeTest
903
900
isTypeOf : { } ,
904
- fields : { f : { type : GraphQLString } } ,
905
901
} ) ,
906
902
) ;
907
903
} ) . to . throw (
@@ -947,12 +943,10 @@ describe('Type System: Union types must be array', () => {
947
943
it ( 'rejects a Union type with incorrectly typed types' , ( ) => {
948
944
expect ( ( ) =>
949
945
schemaWithFieldType (
950
- // $DisableFlowOnNegativeTest
951
946
new GraphQLUnionType ( {
952
947
name : 'SomeUnion' ,
953
- types : {
954
- ObjectType,
955
- } ,
948
+ // $DisableFlowOnNegativeTest
949
+ types : { ObjectType } ,
956
950
} ) ,
957
951
) ,
958
952
) . to . throw (
@@ -986,9 +980,9 @@ describe('Type System: Input Objects must have fields', () => {
986
980
} ) ;
987
981
988
982
it ( 'rejects an Input Object type with incorrect fields' , ( ) => {
989
- // $DisableFlowOnNegativeTest
990
983
const inputObjType = new GraphQLInputObjectType ( {
991
984
name : 'SomeInputObject' ,
985
+ // $DisableFlowOnNegativeTest
992
986
fields : [ ] ,
993
987
} ) ;
994
988
expect ( ( ) => inputObjType . getFields ( ) ) . to . throw (
@@ -998,12 +992,10 @@ describe('Type System: Input Objects must have fields', () => {
998
992
} ) ;
999
993
1000
994
it ( 'rejects an Input Object type with fields function that returns incorrect type' , ( ) => {
1001
- // $DisableFlowOnNegativeTest
1002
995
const inputObjType = new GraphQLInputObjectType ( {
1003
996
name : 'SomeInputObject' ,
1004
- fields ( ) {
1005
- return [ ] ;
1006
- } ,
997
+ // $DisableFlowOnNegativeTest
998
+ fields : ( ) => [ ] ,
1007
999
} ) ;
1008
1000
expect ( ( ) => inputObjType . getFields ( ) ) . to . throw (
1009
1001
'SomeInputObject fields must be an object with field names as keys or a ' +
@@ -1014,16 +1006,11 @@ describe('Type System: Input Objects must have fields', () => {
1014
1006
1015
1007
describe ( 'Type System: Input Object fields must not have resolvers' , ( ) => {
1016
1008
it ( 'rejects an Input Object type with resolvers' , ( ) => {
1017
- // $DisableFlowOnNegativeTest
1018
1009
const inputObjType = new GraphQLInputObjectType ( {
1019
1010
name : 'SomeInputObject' ,
1020
1011
fields : {
1021
- f : {
1022
- type : GraphQLString ,
1023
- resolve : ( ) => {
1024
- return 0 ;
1025
- } ,
1026
- } ,
1012
+ // $DisableFlowOnNegativeTest
1013
+ f : { type : GraphQLString , resolve : ( ) => 0 } ,
1027
1014
} ,
1028
1015
} ) ;
1029
1016
expect ( ( ) => inputObjType . getFields ( ) ) . to . throw (
@@ -1033,14 +1020,11 @@ describe('Type System: Input Object fields must not have resolvers', () => {
1033
1020
} ) ;
1034
1021
1035
1022
it ( 'rejects an Input Object type with resolver constant' , ( ) => {
1036
- // $DisableFlowOnNegativeTest
1037
1023
const inputObjType = new GraphQLInputObjectType ( {
1038
1024
name : 'SomeInputObject' ,
1039
1025
fields : {
1040
- f : {
1041
- type : GraphQLString ,
1042
- resolve : { } ,
1043
- } ,
1026
+ // $DisableFlowOnNegativeTest
1027
+ f : { type : GraphQLString , resolve : { } } ,
1044
1028
} ,
1045
1029
} ) ;
1046
1030
expect ( ( ) => inputObjType . getFields ( ) ) . to . throw (
@@ -1078,9 +1062,9 @@ describe('Type System: Enum types must be well defined', () => {
1078
1062
it ( 'rejects an Enum type with incorrectly typed values' , ( ) => {
1079
1063
const config = {
1080
1064
name : 'SomeEnum' ,
1065
+ // $DisableFlowOnNegativeTest
1081
1066
values : [ { FOO : 10 } ] ,
1082
1067
} ;
1083
- // $DisableFlowOnNegativeTest
1084
1068
expect ( ( ) => new GraphQLEnumType ( config ) ) . to . throw (
1085
1069
'SomeEnum values must be an object with value names as keys.' ,
1086
1070
) ;
@@ -1089,9 +1073,9 @@ describe('Type System: Enum types must be well defined', () => {
1089
1073
it ( 'rejects an Enum type with missing value definition' , ( ) => {
1090
1074
const config = {
1091
1075
name : 'SomeEnum' ,
1076
+ // $DisableFlowOnNegativeTest
1092
1077
values : { FOO : null } ,
1093
1078
} ;
1094
- // $DisableFlowOnNegativeTest
1095
1079
expect ( ( ) => new GraphQLEnumType ( config ) ) . to . throw (
1096
1080
'SomeEnum.FOO must refer to an object with a "value" key representing ' +
1097
1081
'an internal value but got: null.' ,
@@ -1101,9 +1085,9 @@ describe('Type System: Enum types must be well defined', () => {
1101
1085
it ( 'rejects an Enum type with incorrectly typed value definition' , ( ) => {
1102
1086
const config = {
1103
1087
name : 'SomeEnum' ,
1088
+ // $DisableFlowOnNegativeTest
1104
1089
values : { FOO : 10 } ,
1105
1090
} ;
1106
- // $DisableFlowOnNegativeTest
1107
1091
expect ( ( ) => new GraphQLEnumType ( config ) ) . to . throw (
1108
1092
'SomeEnum.FOO must refer to an object with a "value" key representing ' +
1109
1093
'an internal value but got: 10.' ,
@@ -1114,12 +1098,10 @@ describe('Type System: Enum types must be well defined', () => {
1114
1098
const config = {
1115
1099
name : 'SomeEnum' ,
1116
1100
values : {
1117
- FOO : {
1118
- isDeprecated : true ,
1119
- } ,
1101
+ // $DisableFlowOnNegativeTest
1102
+ FOO : { isDeprecated : true } ,
1120
1103
} ,
1121
1104
} ;
1122
- // $DisableFlowOnNegativeTest
1123
1105
expect ( ( ) => new GraphQLEnumType ( config ) ) . to . throw (
1124
1106
'SomeEnum.FOO should provide "deprecationReason" instead ' +
1125
1107
'of "isDeprecated".' ,
0 commit comments