func (executor *ParallelExecutor) Execute(ctx *ExecutionContext) (map[string]interface{}, error) {
	result := map[string]interface{}{}
	resultCh := make(chan *queryExecutionResult, 10)
	defer close(resultCh)
	stepWg := &sync.WaitGroup{}
	errMutex := &sync.Mutex{}
	errCh := make(chan error, 10)
	defer close(errCh)
	closeCh := make(chan bool)
	defer close(closeCh)
	resultLock := &sync.Mutex{}
	if len(ctx.Plan.RootStep.Then) == 0 {
		return nil, errors.New("was given empty plan")
	}
	for _, step := range ctx.Plan.RootStep.Then {
		stepWg.Add(1)
		go executeStep(ctx, ctx.Plan, step, []string{}, resultLock, ctx.Variables, resultCh, errCh, stepWg)
	}
	errs := graphql.ErrorList{}
	go func() {
		for {
			select {
			case payload := <-resultCh:
				if payload == nil {
					continue
				}
				log.Debug("Inserting result into ", payload.InsertionPoint)
				log.Debug("Result: ", payload.Result)
				err := executorInsertObject(result, resultLock, payload.InsertionPoint, payload.Result)
				if err != nil {
					errCh <- err
					continue
				}
				log.Debug("Done. ", result)
				stepWg.Done()
			case err := <-errCh:
				if err != nil {
					errMutex.Lock()
					if errList, ok := err.(graphql.ErrorList); ok {
						errs = append(errs, errList...)
					} else {
						errs = append(errs, err)
					}
					errMutex.Unlock()
					stepWg.Done()
				}
			case <-closeCh:
				return
			}
		}
	}()
	stepWg.Wait()
	errMutex.Lock()
	nErrs := len(errs)
	defer errMutex.Unlock()
	if nErrs > 0 {
		return result, errs
	}
	return result, nil
}
Execute returns the result of the query plan
package gateway
import (
	"context"
	"errors"
	"fmt"
	"strconv"
	"strings"
	"sync"
	"github.com/nautilus/graphql"
	"github.com/vektah/gqlparser/v2/ast"
)
type Executor interface {
	Execute(ctx *ExecutionContext) (map[string]interface{}, error)
}
type ParallelExecutor struct{}
type queryExecutionResult struct {
	InsertionPoint []string
	Result         map[string]interface{}
	StripNode      bool
}
type ExecutionContext struct {
	Plan               *QueryPlan
	Variables          map[string]interface{}
	RequestContext     context.Context
	RequestMiddlewares []graphql.NetworkMiddleware
}