Skip to content

Commit

Permalink
Add gripql sort and print
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewpeterkort committed Jan 21, 2025
1 parent e63f8a4 commit 9ea6b25
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gripql/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ func (q *Query) ToType(field string, typeName string) *Query {
return q.with(&GraphStatement{Statement: &GraphStatement_Totype{Totype: &ToType{Field: field, TypeName: typeName}}})
}

func (q *Query) Sort(sortFields []*SortField) *Query {
return q.with(&GraphStatement{Statement: &GraphStatement_Sort{Sort: &Sorting{Fields: sortFields}}})
}

func (q *Query) String() string {
parts := []string{}
add := func(name string, x ...string) {
Expand Down Expand Up @@ -317,6 +321,9 @@ func (q *Query) String() string {
case *GraphStatement_Totype:
add("Totype", fmt.Sprintf("%s", stmt.Totype.Field), fmt.Sprintf("%s", stmt.Totype.TypeName))

case *GraphStatement_Sort:
add("Sort", fmt.Sprintf("%s", stmt.Sort.Fields))

case *GraphStatement_Render:
jtxt, err := protojson.Marshal(stmt.Render)
if err != nil {
Expand Down

0 comments on commit 9ea6b25

Please sign in to comment.