From 1873de1ce2b774b14ea3f79e86e33526c43a6686 Mon Sep 17 00:00:00 2001 From: Michael Boke Date: Wed, 20 Sep 2023 16:13:17 +0200 Subject: [PATCH] Bugfix When the base graphql operation is in lower case the generated 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 --- clientgenv2/source_generator.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clientgenv2/source_generator.go b/clientgenv2/source_generator.go index 1e142b1..d4c6bae 100644 --- a/clientgenv2/source_generator.go +++ b/clientgenv2/source_generator.go @@ -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" @@ -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 {