Skip to content

Commit

Permalink
Yield introspected input fields in deterministic order
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Jul 14, 2022
1 parent 11917e0 commit b2134d2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"reflect"
"sort"
"strings"

"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/printer"
Expand Down Expand Up @@ -618,6 +619,12 @@ func init() {
for _, field := range ttype.Fields() {
fields = append(fields, field)
}

// Sort args so that their order is deterministic (alpha-numeric descending)
sort.Slice(fields, func(i, j int) bool {
return strings.Compare(fields[i].Name(), fields[j].Name()) == -1
})

return fields, nil
}
return nil, nil
Expand Down

0 comments on commit b2134d2

Please sign in to comment.