@@ -558,9 +558,9 @@ export class GraphQLScalarType {
558
558
this . parseValue = parseValue ;
559
559
this . parseLiteral =
560
560
config . parseLiteral || ( node => parseValue ( valueFromASTUntyped ( node ) ) ) ;
561
-
562
561
this . astNode = config . astNode ;
563
562
this . extensionASTNodes = undefineIfEmpty ( config . extensionASTNodes ) ;
563
+
564
564
devAssert ( typeof config . name === 'string' , 'Must provide name.' ) ;
565
565
devAssert (
566
566
config . serialize == null || typeof config . serialize === 'function' ,
@@ -663,19 +663,20 @@ export type GraphQLScalarTypeConfig<TInternal, TExternal> = {|
663
663
export class GraphQLObjectType {
664
664
name : string ;
665
665
description: ?string ;
666
+ isTypeOf: ?GraphQLIsTypeOfFn < * , * > ;
666
667
astNode: ?ObjectTypeDefinitionNode ;
667
668
extensionASTNodes: ?$ReadOnlyArray < ObjectTypeExtensionNode > ;
668
- isTypeOf: ?GraphQLIsTypeOfFn < * , * > ;
669
669
670
670
_fields: Thunk < GraphQLFieldMap < * , * > > ;
671
671
_interfaces: Thunk < Array < GraphQLInterfaceType >> ;
672
672
673
673
constructor ( config : GraphQLObjectTypeConfig < * , * > ) : void {
674
674
this. name = config . name ;
675
675
this . description = config . description ;
676
+ this . isTypeOf = config . isTypeOf ;
676
677
this . astNode = config . astNode ;
677
678
this . extensionASTNodes = undefineIfEmpty ( config . extensionASTNodes ) ;
678
- this . isTypeOf = config . isTypeOf ;
679
+
679
680
this . _fields = defineFieldMap . bind ( undefined , config ) ;
680
681
this . _interfaces = defineInterfaces . bind ( undefined , config ) ;
681
682
devAssert ( typeof config . name === 'string' , 'Must provide name.' ) ;
@@ -709,9 +710,9 @@ export class GraphQLObjectType {
709
710
return {
710
711
name : this . name ,
711
712
description : this . description ,
712
- isTypeOf : this . isTypeOf ,
713
713
interfaces : this . getInterfaces ( ) ,
714
714
fields : fieldsToFieldsConfig ( this . getFields ( ) ) ,
715
+ isTypeOf : this . isTypeOf ,
715
716
astNode : this . astNode ,
716
717
extensionASTNodes : this . extensionASTNodes || [ ] ,
717
718
} ;
@@ -797,12 +798,12 @@ function isPlainObj(obj) {
797
798
798
799
function fieldsToFieldsConfig ( fields ) {
799
800
return mapValue ( fields , field => ( {
801
+ description : field . description ,
800
802
type : field . type ,
801
803
args : argsToArgsConfig ( field . args ) ,
802
804
resolve : field . resolve ,
803
805
subscribe : field . subscribe ,
804
806
deprecationReason : field . deprecationReason ,
805
- description : field . description ,
806
807
astNode : field . astNode ,
807
808
} ) ) ;
808
809
}
@@ -814,20 +815,20 @@ export function argsToArgsConfig(
814
815
args ,
815
816
arg => arg . name ,
816
817
arg => ( {
818
+ description : arg . description ,
817
819
type : arg . type ,
818
820
defaultValue : arg . defaultValue ,
819
- description : arg . description ,
820
821
astNode : arg . astNode ,
821
822
} ) ,
822
823
) ;
823
824
}
824
825
825
826
export type GraphQLObjectTypeConfig < TSource , TContext > = { |
826
827
name : string ,
828
+ description ?: ?string ,
827
829
interfaces ?: Thunk < ?Array < GraphQLInterfaceType >> ,
828
830
fields : Thunk < GraphQLFieldConfigMap < TSource , TContext> > ,
829
831
isTypeOf ?: ?GraphQLIsTypeOfFn < TSource , TContext> ,
830
- description ?: ?string ,
831
832
astNode ?: ?ObjectTypeDefinitionNode ,
832
833
extensionASTNodes ?: ?$ReadOnlyArray < ObjectTypeExtensionNode > ,
833
834
| } ;
@@ -874,21 +875,21 @@ export type GraphQLFieldConfig<
874
875
TContext ,
875
876
TArgs = { [ argument : string ] : any , ... } ,
876
877
> = { |
878
+ description ?: ?string ,
877
879
type : GraphQLOutputType ,
878
880
args ?: GraphQLFieldConfigArgumentMap ,
879
881
resolve ?: GraphQLFieldResolver < TSource , TContext, TArgs> ,
880
882
subscribe ?: GraphQLFieldResolver < TSource , TContext, TArgs> ,
881
883
deprecationReason ?: ?string ,
882
- description ?: ?string ,
883
884
astNode ?: ?FieldDefinitionNode ,
884
885
| } ;
885
886
886
887
export type GraphQLFieldConfigArgumentMap = ObjMap < GraphQLArgumentConfig > ;
887
888
888
889
export type GraphQLArgumentConfig = { |
890
+ description ?: ?string ,
889
891
type : GraphQLInputType ,
890
892
defaultValue ?: mixed ,
891
- description ?: ?string ,
892
893
astNode ?: ?InputValueDefinitionNode ,
893
894
| } ;
894
895
@@ -914,9 +915,9 @@ export type GraphQLField<
914
915
915
916
export type GraphQLArgument = { |
916
917
name : string ,
918
+ description ?: ?string ,
917
919
type : GraphQLInputType ,
918
920
defaultValue ?: mixed ,
919
- description ?: ?string ,
920
921
astNode ?: ?InputValueDefinitionNode ,
921
922
| } ;
922
923
@@ -949,18 +950,19 @@ export type GraphQLFieldMap<TSource, TContext> = ObjMap<
949
950
export class GraphQLInterfaceType {
950
951
name : string ;
951
952
description : ?string ;
953
+ resolveType : ?GraphQLTypeResolver < * , * > ;
952
954
astNode : ?InterfaceTypeDefinitionNode ;
953
955
extensionASTNodes : ?$ReadOnlyArray < InterfaceTypeExtensionNode > ;
954
- resolveType : ?GraphQLTypeResolver < * , * > ;
955
956
956
957
_fields : Thunk < GraphQLFieldMap < * , * >> ;
957
958
958
959
constructor ( config : GraphQLInterfaceTypeConfig < * , * > ) : void {
959
960
this . name = config . name ;
960
961
this . description = config . description ;
962
+ this . resolveType = config . resolveType ;
961
963
this . astNode = config . astNode ;
962
964
this . extensionASTNodes = undefineIfEmpty ( config . extensionASTNodes ) ;
963
- this . resolveType = config . resolveType ;
965
+
964
966
this . _fields = defineFieldMap . bind ( undefined , config ) ;
965
967
devAssert ( typeof config . name === 'string' , 'Must provide name.' ) ;
966
968
devAssert (
@@ -985,8 +987,8 @@ export class GraphQLInterfaceType {
985
987
return {
986
988
name : this . name ,
987
989
description : this . description ,
988
- resolveType : this . resolveType ,
989
990
fields : fieldsToFieldsConfig ( this . getFields ( ) ) ,
991
+ resolveType : this . resolveType ,
990
992
astNode : this . astNode ,
991
993
extensionASTNodes : this . extensionASTNodes || [ ] ,
992
994
} ;
@@ -1003,14 +1005,14 @@ defineToJSON(GraphQLInterfaceType);
1003
1005
1004
1006
export type GraphQLInterfaceTypeConfig < TSource , TContext > = { |
1005
1007
name : string ,
1008
+ description ?: ?string ,
1006
1009
fields : Thunk < GraphQLFieldConfigMap < TSource , TContext> > ,
1007
1010
/**
1008
1011
* Optionally provide a custom type resolver function. If one is not provided,
1009
1012
* the default implementation will call `isTypeOf` on each implementing
1010
1013
* Object type.
1011
1014
*/
1012
1015
resolveType ?: ?GraphQLTypeResolver < TSource , TContext> ,
1013
- description ?: ?string ,
1014
1016
astNode ?: ?InterfaceTypeDefinitionNode ,
1015
1017
extensionASTNodes ?: ?$ReadOnlyArray < InterfaceTypeExtensionNode > ,
1016
1018
| } ;
@@ -1041,18 +1043,19 @@ export type GraphQLInterfaceTypeConfig<TSource, TContext> = {|
1041
1043
export class GraphQLUnionType {
1042
1044
name : string ;
1043
1045
description: ?string ;
1046
+ resolveType: ?GraphQLTypeResolver < * , * > ;
1044
1047
astNode: ?UnionTypeDefinitionNode ;
1045
1048
extensionASTNodes: ?$ReadOnlyArray < UnionTypeExtensionNode > ;
1046
- resolveType: ?GraphQLTypeResolver < * , * > ;
1047
1049
1048
1050
_types: Thunk < Array < GraphQLObjectType >> ;
1049
1051
1050
1052
constructor ( config : GraphQLUnionTypeConfig < * , * > ) : void {
1051
1053
this. name = config . name ;
1052
1054
this . description = config . description ;
1055
+ this . resolveType = config . resolveType ;
1053
1056
this . astNode = config . astNode ;
1054
1057
this . extensionASTNodes = undefineIfEmpty ( config . extensionASTNodes ) ;
1055
- this . resolveType = config . resolveType ;
1058
+
1056
1059
this . _types = defineTypes . bind ( undefined , config ) ;
1057
1060
devAssert ( typeof config . name === 'string' , 'Must provide name.' ) ;
1058
1061
devAssert (
@@ -1077,8 +1080,8 @@ export class GraphQLUnionType {
1077
1080
return {
1078
1081
name : this . name ,
1079
1082
description : this . description ,
1080
- resolveType : this . resolveType ,
1081
1083
types : this . getTypes ( ) ,
1084
+ resolveType : this . resolveType ,
1082
1085
astNode : this . astNode ,
1083
1086
extensionASTNodes : this . extensionASTNodes || [ ] ,
1084
1087
} ;
@@ -1106,14 +1109,14 @@ function defineTypes(
1106
1109
1107
1110
export type GraphQLUnionTypeConfig < TSource , TContext > = { |
1108
1111
name : string ,
1112
+ description ?: ?string ,
1109
1113
types : Thunk < Array < GraphQLObjectType >> ,
1110
1114
/**
1111
1115
* Optionally provide a custom type resolver function. If one is not provided,
1112
1116
* the default implementation will call `isTypeOf` on each implementing
1113
1117
* Object type.
1114
1118
*/
1115
1119
resolveType ?: ?GraphQLTypeResolver < TSource , TContext> ,
1116
- description ?: ?string ,
1117
1120
astNode ?: ?UnionTypeDefinitionNode ,
1118
1121
extensionASTNodes ?: ?$ReadOnlyArray < UnionTypeExtensionNode > ,
1119
1122
| } ;
@@ -1154,6 +1157,7 @@ export class GraphQLEnumType /* <T> */ {
1154
1157
this . description = config . description ;
1155
1158
this . astNode = config . astNode ;
1156
1159
this . extensionASTNodes = undefineIfEmpty ( config . extensionASTNodes ) ;
1160
+
1157
1161
this . _values = defineEnumValues ( this . name , config . values ) ;
1158
1162
this . _valueLookup = new Map (
1159
1163
this . _values . map ( enumValue => [ enumValue . value , enumValue ] ) ,
@@ -1251,38 +1255,38 @@ function defineEnumValues(
1251
1255
return {
1252
1256
name : valueName ,
1253
1257
description : value . description ,
1258
+ value : 'value' in value ? value . value : valueName ,
1254
1259
isDeprecated : Boolean ( value . deprecationReason ) ,
1255
1260
deprecationReason : value . deprecationReason ,
1256
1261
astNode : value . astNode ,
1257
- value : 'value' in value ? value . value : valueName ,
1258
1262
} ;
1259
1263
} ) ;
1260
1264
}
1261
1265
1262
1266
export type GraphQLEnumTypeConfig /* <T> */ = { |
1263
1267
name : string ,
1264
- values : GraphQLEnumValueConfigMap /* <T> */ ,
1265
1268
description ?: ?string ,
1269
+ values : GraphQLEnumValueConfigMap /* <T> */ ,
1266
1270
astNode ?: ?EnumTypeDefinitionNode ,
1267
1271
extensionASTNodes ?: ?$ReadOnlyArray < EnumTypeExtensionNode > ,
1268
1272
| } ;
1269
1273
1270
1274
export type GraphQLEnumValueConfigMap /* <T> */ = ObjMap < GraphQLEnumValueConfig /* <T> */ > ;
1271
1275
1272
1276
export type GraphQLEnumValueConfig /* <T> */ = { |
1277
+ description ?: ?string ,
1273
1278
value ?: any /* T */ ,
1274
1279
deprecationReason ?: ?string ,
1275
- description ?: ?string ,
1276
1280
astNode ?: ?EnumValueDefinitionNode ,
1277
1281
| } ;
1278
1282
1279
1283
export type GraphQLEnumValue /* <T> */ = { |
1280
1284
name : string ,
1281
1285
description : ?string ,
1286
+ value : any /* T */ ,
1282
1287
isDeprecated ?: boolean ,
1283
1288
deprecationReason : ?string ,
1284
1289
astNode ?: ?EnumValueDefinitionNode ,
1285
- value : any /* T */ ,
1286
1290
| } ;
1287
1291
1288
1292
/**
@@ -1318,6 +1322,7 @@ export class GraphQLInputObjectType {
1318
1322
this . description = config . description ;
1319
1323
this . astNode = config . astNode ;
1320
1324
this . extensionASTNodes = undefineIfEmpty ( config . extensionASTNodes ) ;
1325
+
1321
1326
this . _fields = defineInputFieldMap . bind ( undefined , config ) ;
1322
1327
devAssert ( typeof config . name === 'string' , 'Must provide name.' ) ;
1323
1328
}
@@ -1375,36 +1380,36 @@ function defineInputFieldMap(
1375
1380
1376
1381
return {
1377
1382
name : fieldName ,
1383
+ description : fieldConfig . description ,
1378
1384
type : fieldConfig . type ,
1379
1385
defaultValue : fieldConfig . defaultValue ,
1380
- description : fieldConfig . description ,
1381
1386
astNode : fieldConfig . astNode ,
1382
1387
} ;
1383
1388
} ) ;
1384
1389
}
1385
1390
1386
1391
export type GraphQLInputObjectTypeConfig = { |
1387
1392
name : string ,
1388
- fields : Thunk < GraphQLInputFieldConfigMap > ,
1389
1393
description ?: ?string ,
1394
+ fields : Thunk < GraphQLInputFieldConfigMap > ,
1390
1395
astNode ?: ?InputObjectTypeDefinitionNode ,
1391
1396
extensionASTNodes ?: ?$ReadOnlyArray < InputObjectTypeExtensionNode > ,
1392
1397
| } ;
1393
1398
1394
1399
export type GraphQLInputFieldConfig = { |
1400
+ description ?: ?string ,
1395
1401
type : GraphQLInputType ,
1396
1402
defaultValue ?: mixed ,
1397
- description ?: ?string ,
1398
1403
astNode ?: ?InputValueDefinitionNode ,
1399
1404
| } ;
1400
1405
1401
1406
export type GraphQLInputFieldConfigMap = ObjMap < GraphQLInputFieldConfig > ;
1402
1407
1403
1408
export type GraphQLInputField = { |
1404
1409
name : string ,
1410
+ description ?: ?string ,
1405
1411
type : GraphQLInputType ,
1406
1412
defaultValue ?: mixed ,
1407
- description ?: ?string ,
1408
1413
astNode ?: ?InputValueDefinitionNode ,
1409
1414
| } ;
1410
1415
0 commit comments