Skip to content

Commit

Permalink
wip: Adhere to the code review and the doc-restructure work.
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Jun 28, 2022
1 parent d91ae42 commit 71aa2a5
Show file tree
Hide file tree
Showing 3 changed files with 333 additions and 75 deletions.
36 changes: 25 additions & 11 deletions query/graphql/planner/sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,34 @@ func (n *sumNode) Source() planNode { return n.plan }
// Explain method returns a map containing all attributes of this node that
// are to be explained, subscribes / opts-in this node to be an explainablePlanNode.
func (n *sumNode) Explain() (map[string]interface{}, error) {
explainerMap := map[string]interface{}{}
sourceExplanations := make([]map[string]interface{}, len(n.aggregateMapping))

// Add the filter attribute if it exists.
if n.filter == nil || n.filter.Conditions == nil {
explainerMap[filterLabel] = nil
} else {
explainerMap[filterLabel] = n.filter.Conditions
}
for i, source := range n.aggregateMapping {
explainerMap := map[string]interface{}{}

// Add the other attributes.
explainerMap["sourceCollection"] = n.sourceCollection
explainerMap["sourceProperty"] = n.sourceProperty
// Add the filter attribute if it exists.
if source.Filter == nil || source.Filter.ExternalConditions == nil {
explainerMap[filterLabel] = nil
} else {
explainerMap[filterLabel] = source.Filter.ExternalConditions
}

return explainerMap, nil
// Add the main field name.
explainerMap["fieldName"] = source.Field.Name

// Add the child field name if it exists.
if source.ChildTarget.HasValue {
explainerMap["childFieldName"] = source.ChildTarget.Name
} else {
explainerMap["childFieldName"] = nil
}

sourceExplanations[i] = explainerMap
}

return map[string]interface{}{
"sources": sourceExplanations,
}, nil
}

func (n *sumNode) Next() (bool, error) {
Expand Down
1 change: 1 addition & 0 deletions tests/integration/query/explain/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var bookAuthorGQLSchema = (`
type article {
name: String
author: author
pages: Int
}
type book {
Expand Down
Loading

0 comments on commit 71aa2a5

Please sign in to comment.