@@ -333,8 +333,8 @@ function executeOperation(
333
333
exeContext ,
334
334
type ,
335
335
operation . selectionSet ,
336
- Object . create ( null ) ,
337
- Object . create ( null ) ,
336
+ new Map ( ) ,
337
+ new Set ( ) ,
338
338
) ;
339
339
340
340
const path = undefined ;
@@ -369,12 +369,11 @@ function executeFieldsSerially(
369
369
parentType : GraphQLObjectType ,
370
370
sourceValue : mixed ,
371
371
path : Path | void ,
372
- fields : ObjMap < Array < FieldNode > > ,
372
+ fields : Map < string , Array < FieldNode > > ,
373
373
) : PromiseOrValue < ObjMap < mixed > > {
374
374
return promiseReduce (
375
- Object . keys ( fields ) ,
376
- ( results , responseName ) => {
377
- const fieldNodes = fields [ responseName ] ;
375
+ fields . entries ( ) ,
376
+ ( results , [ responseName , fieldNodes ] ) => {
378
377
const fieldPath = addPath ( path , responseName , parentType . name ) ;
379
378
const result = resolveField (
380
379
exeContext ,
@@ -408,13 +407,12 @@ function executeFields(
408
407
parentType: GraphQLObjectType,
409
408
sourceValue: mixed,
410
409
path: Path | void,
411
- fields: ObjMap < Array < FieldNode > > ,
410
+ fields: Map < string , Array < FieldNode > > ,
412
411
) : PromiseOrValue < ObjMap < mixed > > {
413
412
const results = Object . create ( null ) ;
414
413
let containsPromise = false ;
415
414
416
- for ( const responseName of Object . keys ( fields ) ) {
417
- const fieldNodes = fields [ responseName ] ;
415
+ for ( const [ responseName , fieldNodes ] of fields . entries ( ) ) {
418
416
const fieldPath = addPath ( path , responseName , parentType . name ) ;
419
417
const result = resolveField (
420
418
exeContext ,
@@ -457,20 +455,22 @@ export function collectFields(
457
455
exeContext : ExecutionContext ,
458
456
runtimeType : GraphQLObjectType ,
459
457
selectionSet : SelectionSetNode ,
460
- fields : ObjMap < Array < FieldNode > > ,
461
- visitedFragmentNames : ObjMap < boolean > ,
462
- ): ObjMap < Array < FieldNode > > {
458
+ fields : Map < string , Array < FieldNode > > ,
459
+ visitedFragmentNames : Set < string > ,
460
+ ): Map < string , Array < FieldNode > > {
463
461
for ( const selection of selectionSet . selections ) {
464
462
switch ( selection . kind ) {
465
463
case Kind . FIELD : {
466
464
if ( ! shouldIncludeNode ( exeContext , selection ) ) {
467
465
continue ;
468
466
}
469
467
const name = getFieldEntryKey ( selection ) ;
470
- if ( ! fields [ name ] ) {
471
- fields [ name ] = [ ] ;
468
+ const fieldList = fields . get ( name ) ;
469
+ if ( fieldList !== undefined ) {
470
+ fieldList . push ( selection ) ;
471
+ } else {
472
+ fields . set ( name , [ selection ] ) ;
472
473
}
473
- fields [ name ] . push ( selection ) ;
474
474
break ;
475
475
}
476
476
case Kind . INLINE_FRAGMENT : {
@@ -492,12 +492,12 @@ export function collectFields(
492
492
case Kind . FRAGMENT_SPREAD : {
493
493
const fragName = selection . name . value ;
494
494
if (
495
- visitedFragmentNames [ fragName ] ||
495
+ visitedFragmentNames . has ( fragName ) ||
496
496
! shouldIncludeNode ( exeContext , selection )
497
497
) {
498
498
continue ;
499
499
}
500
- visitedFragmentNames [ fragName ] = true ;
500
+ visitedFragmentNames . add ( fragName ) ;
501
501
const fragment = exeContext . fragments [ fragName ] ;
502
502
if (
503
503
! fragment ||
@@ -1085,9 +1085,9 @@ function _collectSubfields(
1085
1085
exeContext : ExecutionContext ,
1086
1086
returnType : GraphQLObjectType ,
1087
1087
fieldNodes : $ReadOnlyArray < FieldNode > ,
1088
- ) : ObjMap < Array < FieldNode > > {
1089
- let subFieldNodes = Object . create ( null ) ;
1090
- const visitedFragmentNames = Object . create ( null ) ;
1088
+ ) : Map < string , Array < FieldNode > > {
1089
+ let subFieldNodes = new Map ( ) ;
1090
+ const visitedFragmentNames = new Set ( ) ;
1091
1091
for ( const node of fieldNodes ) {
1092
1092
if ( node . selectionSet ) {
1093
1093
subFieldNodes = collectFields (
0 commit comments