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

Fix a bug in type-name collapsing introduced by #71 #110

Merged
merged 1 commit into from
Sep 23, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ When releasing a new version:

### Bug fixes:

- Generated type-names now abbreviate across multiple components; for example if the path to a type is `(MyOperation, Outer, Outer, Inner, OuterInner)`, it will again be called `MyOperationOuterInner`. (This regressed in a pre-v0.1.0 refactor.) (#109)

## v0.1.0

First open-sourced version.
4 changes: 2 additions & 2 deletions generate/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ func typeNameParts(prefix *prefixList, typeName string) *prefixList {
// If the prefix has just one part, that's the operation-name. There's no
// need to add "Query" or "Mutation". (Zero should never happen.)
if prefix == nil || prefix.tail == nil ||
// If the last prefix field ends with this type's name, omit the
// If the name-so-far ends with this type's name, omit the
// type-name (see the "shortened" case in the top-of-file comment).
strings.HasSuffix(prefix.head, typeName) {
strings.HasSuffix(joinPrefixList(prefix), typeName) {
return prefix
}
return &prefixList{typeName, prefix}
Expand Down
4 changes: 2 additions & 2 deletions generate/names_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestTypeNames(t *testing.T) {
[]*ast.Field{fakeField("Query", "operationUser")},
"User",
}, {
// We don't shorten across multiple prefixes.
"OperationUserOperationUser",
// We do shorten across multiple prefixes.
"OperationUser",
[]*ast.Field{fakeField("Query", "user")},
"OperationUser",
}, {
Expand Down