Skip to content

Commit

Permalink
wip: Add implementation of explaining sortNode attribute(s).
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Jun 24, 2022
1 parent 37c06b1 commit 3512e0c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions query/graphql/planner/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type sortNode struct {
// that sorts, then provides the values
// sorted
sortStrategy sortingStrategy

// indicates if our underlying sortStrategy is still
// consuming and sorting data.
needSort bool
Expand Down Expand Up @@ -94,7 +95,20 @@ func (n *sortNode) Value() map[string]interface{} {
// 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 *sortNode) Explain() (map[string]interface{}, error) {
return map[string]interface{}{}, nil
orderings := []map[string]interface{}{}

for _, element := range n.ordering {
orderings = append(orderings,
map[string]interface{}{
"field": element.Field,
"direction": string(element.Direction),
},
)
}

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

func (n *sortNode) Next() (bool, error) {
Expand All @@ -121,9 +135,6 @@ func (n *sortNode) Next() (bool, error) {
if err := n.sortStrategy.Add(n.plan.Value()); err != nil {
return false, err
}

// finalize, assign valueIter = sortStrategy
// break
}

next, err := n.valueIter.Next()
Expand Down

0 comments on commit 3512e0c

Please sign in to comment.