...
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 for _, ref := range b.Binder.References {
12 processType(ret, ref)
13 }
14 return ret
15 }
16
17 func processType(ret map[string]*config.TypeReference, ref *config.TypeReference) {
18 key := ref.UniquenessKey()
19 if existing, found := ret[key]; found {
20
21 existingGQL := fmt.Sprintf("%v", existing.GQL)
22 newGQL := fmt.Sprintf("%v", ref.GQL)
23 if existingGQL != newGQL {
24 panic(fmt.Sprintf("non-unique key \"%s\", trying to replace %s with %s", key, existingGQL, newGQL))
25 }
26 }
27 ret[key] = ref
28
29 if ref.IsSlice() || ref.IsPtrToSlice() || ref.IsPtrToPtr() || ref.IsPtrToIntf() {
30 processType(ret, ref.Elem())
31 }
32 }
33
View as plain text