From fd09cd9931347475cfc83f67685ff6ef7e815f6b Mon Sep 17 00:00:00 2001 From: He Weiwei Date: Mon, 20 Aug 2018 18:25:42 +0800 Subject: [PATCH] sort directives by name when gen --- codegen/directive_build.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/codegen/directive_build.go b/codegen/directive_build.go index fcc8bdb0bfc..3282884112f 100644 --- a/codegen/directive_build.go +++ b/codegen/directive_build.go @@ -1,6 +1,10 @@ package codegen -import "github.com/pkg/errors" +import ( + "sort" + + "github.com/pkg/errors" +) func (cfg *Config) buildDirectives(types NamedTypes) ([]*Directive, error) { var directives []*Directive @@ -38,5 +42,8 @@ func (cfg *Config) buildDirectives(types NamedTypes) ([]*Directive, error) { Args: args, }) } + + sort.Slice(directives, func(i, j int) bool { return directives[i].Name < directives[j].Name }) + return directives, nil }