Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions v2/pkg/engine/resolve/resolvable.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ func (r *Resolvable) walkArray(arr *Array, value *astjson.Value) bool {
// that resolves an abstract (interface/union) field.
func (r *Resolvable) recordObjectTypeStats(obj *Object, typeName []byte) {
// An array item Object has an empty Path
if len(obj.Path) == 0 || typeName == nil || !obj.isAbstract() {
if len(obj.Path) == 0 || !obj.isAbstract() {
return
}
pathKey := r.currentFieldPath()
Expand All @@ -1033,7 +1033,12 @@ func (r *Resolvable) recordObjectTypeStats(obj *Object, typeName []byte) {
if stats.TypeNames == nil {
stats.TypeNames = make(map[string]int, 1)
}
stats.TypeNames[string(typeName)]++
// Fall back to the declared abstract type name when the subgraph did not return __typename.
name := obj.TypeName
if typeName != nil {
name = string(typeName)
}
stats.TypeNames[name]++
r.typeNameStats[pathKey] = stats
}

Expand Down
Loading