github.com/fortexxx/gqlgen@v0.10.3-0.20191216030626-ca5ea8b21ead/codegen/type.go (about) 1 package codegen 2 3 import ( 4 "fmt" 5 6 "github.com/99designs/gqlgen/codegen/config" 7 ) 8 9 func (b *builder) buildTypes() map[string]*config.TypeReference { 10 ret := map[string]*config.TypeReference{} 11 var key string 12 var existing *config.TypeReference 13 var found bool 14 15 for _, ref := range b.Binder.References { 16 for ref != nil { 17 key = ref.UniquenessKey() 18 if existing, found = ret[key]; found { 19 // Simplistic check of content which is obviously different. 20 existingGQL := fmt.Sprintf("%v", existing.GQL) 21 newGQL := fmt.Sprintf("%v", ref.GQL) 22 if existingGQL != newGQL { 23 panic(fmt.Sprintf("non-unique key \"%s\", trying to replace %s with %s", key, existingGQL, newGQL)) 24 } 25 } 26 ret[key] = ref 27 28 ref = ref.Elem() 29 } 30 } 31 return ret 32 }