@@ -309,6 +309,7 @@ export class GraphQLScalarType {
309
309
astNode : ?ScalarTypeDefinitionNode ;
310
310
311
311
_scalarConfig : GraphQLScalarTypeConfig < * , * > ;
312
+ _wrappedList : ?GraphQLList < * > ;
312
313
313
314
constructor ( config : GraphQLScalarTypeConfig < * , * > ) : void {
314
315
assertValidName ( config . name ) ;
@@ -367,7 +368,7 @@ export class GraphQLScalarType {
367
368
}
368
369
369
370
wrapList(): GraphQLList< * > {
370
- return new GraphQLList ( this ) ;
371
+ return this . _wrappedList || ( this . _wrappedList = new GraphQLList ( this ) ) ;
371
372
}
372
373
373
374
toJSON: () => string ;
@@ -437,6 +438,7 @@ export class GraphQLObjectType {
437
438
_typeConfig : GraphQLObjectTypeConfig < * , * > ;
438
439
_fields : GraphQLFieldMap < * , * > ;
439
440
_interfaces : Array < GraphQLInterfaceType > ;
441
+ _wrappedList : ?GraphQLList < * > ;
440
442
441
443
constructor ( config : GraphQLObjectTypeConfig < * , * > ) : void {
442
444
assertValidName ( config . name , config . isIntrospection ) ;
@@ -471,7 +473,7 @@ export class GraphQLObjectType {
471
473
}
472
474
473
475
wrapList ( ) : GraphQLList < * > {
474
- return new GraphQLList ( this ) ;
476
+ return this . _wrappedList || ( this . _wrappedList = new GraphQLList ( this ) ) ;
475
477
}
476
478
477
479
toJSON : ( ) => string ;
@@ -726,6 +728,7 @@ export class GraphQLInterfaceType {
726
728
727
729
_typeConfig : GraphQLInterfaceTypeConfig < * , * > ;
728
730
_fields : GraphQLFieldMap < * , * > ;
731
+ _wrappedList : ?GraphQLList < * > ;
729
732
730
733
constructor ( config : GraphQLInterfaceTypeConfig < * , * > ) : void {
731
734
assertValidName ( config . name ) ;
@@ -752,7 +755,7 @@ export class GraphQLInterfaceType {
752
755
}
753
756
754
757
wrapList ( ) : GraphQLList < * > {
755
- return new GraphQLList ( this ) ;
758
+ return this . _wrappedList || ( this . _wrappedList = new GraphQLList ( this ) ) ;
756
759
}
757
760
758
761
toJSON : ( ) => string ;
@@ -810,6 +813,7 @@ export class GraphQLUnionType {
810
813
811
814
_typeConfig : GraphQLUnionTypeConfig < * , * > ;
812
815
_types : Array < GraphQLObjectType > ;
816
+ _wrappedList : ?GraphQLList < * > ;
813
817
814
818
constructor ( config : GraphQLUnionTypeConfig < * , * > ) : void {
815
819
assertValidName ( config . name ) ;
@@ -837,7 +841,7 @@ export class GraphQLUnionType {
837
841
}
838
842
839
843
wrapList ( ) : GraphQLList < * > {
840
- return new GraphQLList ( this ) ;
844
+ return this . _wrappedList || ( this . _wrappedList = new GraphQLList ( this ) ) ;
841
845
}
842
846
843
847
toJSON : ( ) => string ;
@@ -931,6 +935,7 @@ export class GraphQLEnumType/* <T> */ {
931
935
_values : Array < GraphQLEnumValue /* <T> */ > ;
932
936
_valueLookup : Map < any /* T */ , GraphQLEnumValue > ;
933
937
_nameLookup : ObjMap < GraphQLEnumValue > ;
938
+ _wrappedList : ?GraphQLList < * > ;
934
939
935
940
constructor ( config : GraphQLEnumTypeConfig /* <T> */ ) : void {
936
941
this . name = config . name ;
@@ -1009,7 +1014,7 @@ export class GraphQLEnumType/* <T> */ {
1009
1014
}
1010
1015
1011
1016
wrapList ( ) : GraphQLList < * > {
1012
- return new GraphQLList ( this ) ;
1017
+ return this . _wrappedList || ( this . _wrappedList = new GraphQLList ( this ) ) ;
1013
1018
}
1014
1019
1015
1020
toJSON : ( ) = > string ;
@@ -1119,6 +1124,7 @@ export class GraphQLInputObjectType {
1119
1124
1120
1125
_typeConfig : GraphQLInputObjectTypeConfig ;
1121
1126
_fields : GraphQLInputFieldMap ;
1127
+ _wrappedList : ?GraphQLList < * > ;
1122
1128
1123
1129
constructor ( config : GraphQLInputObjectTypeConfig ) : void {
1124
1130
assertValidName ( config . name ) ;
@@ -1172,7 +1178,7 @@ export class GraphQLInputObjectType {
1172
1178
}
1173
1179
1174
1180
wrapList ( ) : GraphQLList < * > {
1175
- return new GraphQLList ( this ) ;
1181
+ return this . _wrappedList || ( this . _wrappedList = new GraphQLList ( this ) ) ;
1176
1182
}
1177
1183
1178
1184
toJSON : ( ) => string ;
@@ -1226,14 +1232,15 @@ export type GraphQLInputFieldMap =
1226
1232
* const PersonType = new GraphQLObjectType({
1227
1233
* name: 'Person',
1228
1234
* fields: () => ({
1229
- * parents: { type: new GraphQLList( Person) },
1230
- * children: { type: new GraphQLList( Person) },
1235
+ * parents: { type: Person.wrapList( ) },
1236
+ * children: { type: Person.wrapList( ) },
1231
1237
* })
1232
1238
* })
1233
1239
*
1234
1240
*/
1235
1241
export class GraphQLList < T : GraphQLType > {
1236
1242
ofType : T ;
1243
+ _wrappedList : ?GraphQLList < * > ;
1237
1244
1238
1245
constructor ( type : T ) : void {
1239
1246
invariant (
@@ -1248,7 +1255,7 @@ export class GraphQLList<T: GraphQLType> {
1248
1255
}
1249
1256
1250
1257
wrapList ( ) : GraphQLList < * > {
1251
- return new GraphQLList ( this ) ;
1258
+ return this . _wrappedList || ( this . _wrappedList = new GraphQLList ( this ) ) ;
1252
1259
}
1253
1260
1254
1261
toJSON : ( ) => string ;
@@ -1283,6 +1290,7 @@ GraphQLList.prototype.toJSON =
1283
1290
*/
1284
1291
export class GraphQLNonNull < T : GraphQLNullableType > {
1285
1292
ofType : T ;
1293
+ _wrappedList : ?GraphQLList < * > ;
1286
1294
1287
1295
constructor ( type : T ) : void {
1288
1296
invariant (
@@ -1298,7 +1306,7 @@ export class GraphQLNonNull<T: GraphQLNullableType> {
1298
1306
}
1299
1307
1300
1308
wrapList ( ) : GraphQLList < * > {
1301
- return new GraphQLList ( this ) ;
1309
+ return this . _wrappedList || ( this . _wrappedList = new GraphQLList ( this ) ) ;
1302
1310
}
1303
1311
1304
1312
toJSON : ( ) = > string ;
0 commit comments