Skip to content

Commit 7fcb93c

Browse files
committed
fix(tool): added a check to see if a generic type was already generated
1 parent 5cf60a2 commit 7fcb93c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

generator/generator.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,21 @@ func (g *Generator) generateConcreteTypesFromInstantiations() error {
18661866
slog.Info("Generating concrete types from instantiations", "count", len(g.GenericInstantiations))
18671867

18681868
for concreteTypeName, inst := range g.GenericInstantiations {
1869+
// Skip if this type was already generated (e.g., explicitly annotated struct)
1870+
alreadyGenerated := false
1871+
for _, item := range g.GeneratedItems {
1872+
if item.GQLName == concreteTypeName {
1873+
slog.Debug("Skipping concrete type generation - already generated",
1874+
"concreteType", concreteTypeName,
1875+
"existingType", item.GoTypeName)
1876+
alreadyGenerated = true
1877+
break
1878+
}
1879+
}
1880+
if alreadyGenerated {
1881+
continue
1882+
}
1883+
18691884
slog.Debug("Processing concrete type",
18701885
"concreteTypeName", concreteTypeName,
18711886
"genericType", inst.GenericTypeName)

gqlschemagen.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ output_file_extension: .graphqls
5252
field_case: camel
5353

5454
# Use json struct tags for field names when gql tag is not present
55+
# This will follow the ignore rules of the json package (e.g., json:"-" to ignore fields)
5556
# Default: true
56-
use_json_tag: true
57+
use_json_tag: true
5758

5859
# Generate gqlgen directives (@goModel, @goField, @goTag)
5960
# Default: false

0 commit comments

Comments
 (0)