Skip to content

Commit 347589d

Browse files
committed
fix hard code for Query
1 parent 075ea22 commit 347589d

File tree

3 files changed

+132
-122
lines changed

3 files changed

+132
-122
lines changed

clientgen/source.go

+10
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ func (s *Source) Query() (*Query, error) {
161161
return nil, xerrors.Errorf("generate failed for query struct type : %w", err)
162162
}
163163

164+
s.sourceGenerator.cfg.Models.Add(
165+
s.schema.Query.Name,
166+
fmt.Sprintf("%s.%s", s.sourceGenerator.client.Pkg(), templates.ToGo(s.schema.Query.Name)),
167+
)
168+
164169
return &Query{
165170
Name: s.schema.Query.Name,
166171
Type: fields.StructType(),
@@ -178,6 +183,11 @@ func (s *Source) Mutation() (*Mutation, error) {
178183
return nil, xerrors.Errorf("generate failed for mutation struct type : %w", err)
179184
}
180185

186+
s.sourceGenerator.cfg.Models.Add(
187+
s.schema.Mutation.Name,
188+
fmt.Sprintf("%s.%s", s.sourceGenerator.client.Pkg(), templates.ToGo(s.schema.Mutation.Name)),
189+
)
190+
181191
return &Mutation{
182192
Name: s.schema.Mutation.Name,
183193
Type: fields.StructType(),

clientgen/source_generator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (r *SourceGenerator) NewResponseFieldsByDefinition(definition *ast.Definiti
9595

9696
var typ types.Type
9797
if field.Type.Name() == "Query" || field.Type.Name() == "Mutation" {
98-
baseType, err := r.binder.FindType(r.client.Pkg().Path(), "Query")
98+
baseType, err := r.binder.FindType(r.client.Pkg().Path(), field.Type.Name())
9999
if err != nil {
100100
return nil, xerrors.Errorf("not found type: %w", err)
101101
}

0 commit comments

Comments
 (0)