Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sergiy/eng 5147 fix usage of fragments on a root query type #792

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions v2/pkg/ast/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ const (
)

type PathItem struct {
Kind PathKind
ArrayIndex int
FieldName ByteSlice
Kind PathKind
ArrayIndex int
FieldName ByteSlice
FragmentRef int // only used for InlineFragmentName, allows to distinguish between multiple inline fragments on the same type
}

type Path []PathItem
Expand All @@ -42,7 +43,11 @@ func (p Path) Equals(another Path) bool {
}
if p[i].Kind == ArrayIndex && p[i].ArrayIndex != another[i].ArrayIndex {
return false
} else if !bytes.Equal(p[i].FieldName, another[i].FieldName) {
}
if !bytes.Equal(p[i].FieldName, another[i].FieldName) {
return false
}
if p[i].FragmentRef != another[i].FragmentRef {
return false
}
}
Expand Down Expand Up @@ -89,6 +94,7 @@ func (p Path) String() string {
}
case InlineFragmentName:
out += InlineFragmentPathPrefix
out += strconv.Itoa(p[i].FragmentRef)
out += unsafebytes.BytesToString(p[i].FieldName)
}
}
Expand Down Expand Up @@ -128,6 +134,7 @@ func (p Path) DotDelimitedString() string {
}
case InlineFragmentName:
builder.WriteString(InlineFragmentPathPrefix)
builder.WriteString(strconv.Itoa(p[i].FragmentRef))
builder.WriteString(unsafebytes.BytesToString(p[i].FieldName))
}
}
Expand Down
5 changes: 3 additions & 2 deletions v2/pkg/astvisitor/visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1411,8 +1411,9 @@ func (w *Walker) appendAncestor(ref int, kind ast.NodeKind) {
}
typeName = w.document.InlineFragmentTypeConditionName(ref)
w.Path = append(w.Path, ast.PathItem{
Kind: ast.InlineFragmentName,
FieldName: typeName,
Kind: ast.InlineFragmentName,
FieldName: typeName,
FragmentRef: ref,
})
case ast.NodeKindFragmentDefinition:
typeName = w.document.FragmentDefinitionTypeName(ref)
Expand Down