diff --git a/query/graphql/planner/planner.go b/query/graphql/planner/planner.go index ceb991e0ed..77a9488a91 100644 --- a/query/graphql/planner/planner.go +++ b/query/graphql/planner/planner.go @@ -429,6 +429,10 @@ func (p *Planner) explainRequest( plan planNode, ) ([]map[string]interface{}, error) { + if plan == nil { + return nil, fmt.Errorf("Can't explain request of a nil plan.") + } + explainGraph, err := buildExplainGraph(plan) if err != nil { return nil, err @@ -449,6 +453,10 @@ func (p *Planner) executeRequest( plan planNode, ) ([]map[string]interface{}, error) { + if plan == nil { + return nil, fmt.Errorf("Can't execute request of a nil plan.") + } + if err := plan.Start(); err != nil { return nil, multiErr(err, plan.Close()) } @@ -491,10 +499,6 @@ func (p *Planner) runRequest( return nil, err } - if plan == nil { - return nil, fmt.Errorf("Can't run request of an empty / nil plan.") - } - isAnExplainRequest := (len(query.Queries) > 0 && query.Queries[0].IsExplain) || (len(query.Mutations) > 0 && query.Mutations[0].IsExplain)