Skip to content

Commit

Permalink
Bugfix When the base graphql operation is in lower case the generated…
Browse files Browse the repository at this point in the history
… response data structures are also generated as private structs (with lower case) but are used in public getter functions.

This bugfix makes sure that the type name always starts with a capital character, so its exported and can be used outside the generated package
  • Loading branch information
michaelboke committed Sep 20, 2023
1 parent 308e653 commit 1873de1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion clientgenv2/source_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package clientgenv2
import (
"fmt"
"go/types"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"strings"

"github.com/99designs/gqlgen/codegen/config"
Expand Down Expand Up @@ -156,7 +158,7 @@ func (r *SourceGenerator) NewResponseFieldsByDefinition(definition *ast.Definiti
}

func NewLayerTypeName(base, thisField string) string {
return fmt.Sprintf("%s_%s", base, thisField)
return fmt.Sprintf("%s_%s", cases.Title(language.Und, cases.NoLower).String(base), thisField)
}

func (r *SourceGenerator) NewResponseField(selection ast.Selection, typeName string) *ResponseField {
Expand Down

0 comments on commit 1873de1

Please sign in to comment.