Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions internal/schema/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ const (
KindNonNull Kind = "NON_NULL"
KindObject Kind = "OBJECT"
KindScalar Kind = "SCALAR"
KindUnion Kind = "UNION"
)
15 changes: 13 additions & 2 deletions internal/schema/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (t *Type) GetQueryStringFields(s *Schema, depth, maxDepth int, isMutation b
lastKind := kinds[len(kinds)-1]

switch lastKind {
case KindObject, KindInterface:
case KindObject, KindInterface, KindUnion:
if depth > maxDepth {
continue
}
Expand All @@ -139,13 +139,24 @@ func (t *Type) GetQueryStringFields(s *Schema, depth, maxDepth int, isMutation b
"depth": depth,
"isMutation": isMutation,
"name": field.Name,
"typeName": subT.Name,
"typeKind": subT.Kind,
}).Trace("skipping, all sub-fields require arguments")
continue
}

log.WithFields(log.Fields{
"depth": depth,
"isMutation": isMutation,
"name": field.Name,
"typeName": subT.Name,
"typeKind": subT.Kind,
"contentLen": len(subTContent),
}).Trace("expanding field")

// Add the field
lines = append(lines, field.Name+" {")
if lastKind == KindInterface {
if lastKind == KindInterface || lastKind == KindUnion {
lines = append(lines, "\t__typename")
}

Expand Down
Loading