diff --git a/lib/schema.go b/lib/schema.go index a0ed7f8..4619c5e 100644 --- a/lib/schema.go +++ b/lib/schema.go @@ -5,6 +5,7 @@ import ( "os" "path/filepath" "reflect" + "sort" "sync" ) @@ -538,6 +539,9 @@ func (s *Schema) MergeTypeName(wg *sync.WaitGroup) { defer wg.Done() j := 0 seen := make(map[string]struct{}, len(s.Types)) + sort.SliceStable(s.Types, func(i, j int) bool { + return !s.Types[i].Extend && s.Types[j].Extend + }) for _, v := range s.Types { if _, ok := seen[v.Name]; ok { for i := 0; i < j; i++ { diff --git a/test/object_extension/schema/a.graphql b/test/object_extension/schema/a.graphql index 77200ec..6b9a6b4 100644 --- a/test/object_extension/schema/a.graphql +++ b/test/object_extension/schema/a.graphql @@ -1,6 +1,3 @@ -type Person implements Node @talkable{ - id: ID! - createTime: Time! - updateTime: Time! - name: String! +extend type Person @walkable { + hasCar: Boolean! } diff --git a/test/object_extension/schema/b.graphql b/test/object_extension/schema/b.graphql index 6b9a6b4..77200ec 100644 --- a/test/object_extension/schema/b.graphql +++ b/test/object_extension/schema/b.graphql @@ -1,3 +1,6 @@ -extend type Person @walkable { - hasCar: Boolean! +type Person implements Node @talkable{ + id: ID! + createTime: Time! + updateTime: Time! + name: String! }