@@ -139,10 +139,10 @@ func joinPrefixList(prefix *prefixList) string {
139139// prefix-list, since it ends with a type, not a field (see top-of-file
140140// comment), but it's used to construct both the type-names from the input and
141141// the next prefix-list.
142- func typeNameParts (prefix * prefixList , typeName string ) * prefixList {
143- // GraphQL types are conventionally UpperCamelCase, but it's not required;
144- // our names will look best if they are.
145- typeName = upperFirst ( typeName )
142+ func typeNameParts (prefix * prefixList , typeName string , algorithm CasingAlgorithm ) * prefixList {
143+ // Apply the specified casing algorithm with uppercase first letter
144+ typeName = ApplyCasing ( typeName , algorithm , true )
145+
146146 // If the prefix has just one part, that's the operation-name. There's no
147147 // need to add "Query" or "Mutation". (Zero should never happen.)
148148 if prefix == nil || prefix .tail == nil ||
@@ -156,27 +156,28 @@ func typeNameParts(prefix *prefixList, typeName string) *prefixList {
156156
157157// Given a prefix-list, and a field, compute the next prefix-list, which will
158158// be used for that field's selections.
159- func nextPrefix (prefix * prefixList , field * ast.Field ) * prefixList {
159+ func nextPrefix (prefix * prefixList , field * ast.Field , algorithm CasingAlgorithm ) * prefixList {
160160 // Add the type.
161- prefix = typeNameParts (prefix , field .ObjectDefinition .Name )
161+ prefix = typeNameParts (prefix , field .ObjectDefinition .Name , algorithm )
162162 // Add the field (there's no shortening here, see top-of-file comment).
163- prefix = & prefixList {upperFirst (field .Alias ), prefix }
163+ fieldAlias := ApplyCasing (field .Alias , algorithm , true )
164+ prefix = & prefixList {fieldAlias , prefix }
164165 return prefix
165166}
166167
167168// Given a prefix-list, and the GraphQL of the current type, compute the name
168169// we should give it in Go.
169- func makeTypeName (prefix * prefixList , typeName string ) string {
170- return joinPrefixList (typeNameParts (prefix , typeName ))
170+ func makeTypeName (prefix * prefixList , typeName string , algorithm CasingAlgorithm ) string {
171+ return joinPrefixList (typeNameParts (prefix , typeName , algorithm ))
171172}
172173
173174// Like makeTypeName, but append typeName unconditionally.
174175//
175176// This is used for when you specify a type-name for a field of interface
176177// type; we use YourName for the interface, but need to do YourNameImplName for
177178// the implementations.
178- func makeLongTypeName (prefix * prefixList , typeName string ) string {
179- typeName = upperFirst (typeName )
179+ func makeLongTypeName (prefix * prefixList , typeName string , algorithm CasingAlgorithm ) string {
180+ typeName = ApplyCasing (typeName , algorithm , true )
180181 return joinPrefixList (& prefixList {typeName , prefix })
181182}
182183
@@ -186,6 +187,8 @@ func (casing *Casing) enumValueName(goTypeName string, enum *ast.Definition, val
186187 return goTypeName + goConstName (val .Name )
187188 case CasingRaw :
188189 return goTypeName + "_" + val .Name
190+ case CasingAutoCamelCase :
191+ return goTypeName + ApplyCasing (val .Name , algo , true )
189192 default :
190193 // Should already be caught by validation.
191194 panic (fmt .Sprintf ("unknown casing algorithm %s" , algo ))
0 commit comments