diff --git a/executor.go b/executor.go index cd0b6653..d680d01f 100644 --- a/executor.go +++ b/executor.go @@ -255,7 +255,7 @@ func executeFieldsSerially(p executeFieldsParams) *Result { p.Fields = map[string][]*ast.Field{} } - finalResults := map[string]interface{}{} + finalResults := make(map[string]interface{}, len(p.Fields)) for responseName, fieldASTs := range p.Fields { resolved, state := resolveField(p.ExecutionContext, p.ParentType, p.Source, fieldASTs) if state.hasNoFieldDefs { @@ -279,7 +279,7 @@ func executeFields(p executeFieldsParams) *Result { p.Fields = map[string][]*ast.Field{} } - finalResults := map[string]interface{}{} + finalResults := make(map[string]interface{}, len(p.Fields)) for responseName, fieldASTs := range p.Fields { resolved, state := resolveField(p.ExecutionContext, p.ParentType, p.Source, fieldASTs) if state.hasNoFieldDefs { @@ -791,7 +791,7 @@ func completeListValue(eCtx *executionContext, returnType *List, fieldASTs []*as } itemType := returnType.OfType - completedResults := []interface{}{} + completedResults := make([]interface{}, 0, resultVal.Len()) for i := 0; i < resultVal.Len(); i++ { val := resultVal.Index(i).Interface() completedItem := completeValueCatchingError(eCtx, itemType, fieldASTs, info, val)