Skip to content

Commit

Permalink
Merge pull request #225 from graphql-go/bigdrum/edge
Browse files Browse the repository at this point in the history
sort fields by name for better reading on introspection
  • Loading branch information
chris-ramon authored Aug 5, 2017
2 parents c68a65c + 08ca841 commit 8e700bf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package graphql
import (
"fmt"
"reflect"
"sort"

"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/graphql/language/printer"
Expand Down Expand Up @@ -518,11 +519,16 @@ func init() {
return nil, nil
}
fields := []*FieldDefinition{}
for _, field := range ttype.Fields() {
var fieldNames sort.StringSlice
for name, field := range ttype.Fields() {
if !includeDeprecated && field.DeprecationReason != "" {
continue
}
fields = append(fields, field)
fieldNames = append(fieldNames, name)
}
sort.Sort(fieldNames)
for _, name := range fieldNames {
fields = append(fields, ttype.Fields()[name])
}
return fields, nil
case *Interface:
Expand Down

0 comments on commit 8e700bf

Please sign in to comment.