Skip to content

Commit

Permalink
fix merging error in reverse order of object extension
Browse files Browse the repository at this point in the history
  • Loading branch information
mununki committed Mar 17, 2024
1 parent 1bbd61a commit 8ceba87
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions lib/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"reflect"
"sort"
"sync"
)

Expand Down Expand Up @@ -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++ {
Expand Down
7 changes: 2 additions & 5 deletions test/object_extension/schema/a.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
type Person implements Node @talkable{
id: ID!
createTime: Time!
updateTime: Time!
name: String!
extend type Person @walkable {
hasCar: Boolean!
}
7 changes: 5 additions & 2 deletions test/object_extension/schema/b.graphql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
extend type Person @walkable {
hasCar: Boolean!
type Person implements Node @talkable{
id: ID!
createTime: Time!
updateTime: Time!
name: String!
}

0 comments on commit 8ceba87

Please sign in to comment.