Skip to content

Commit

Permalink
keep imports when scattering resolvers between files
Browse files Browse the repository at this point in the history
  • Loading branch information
vektah committed Feb 4, 2020
1 parent da7c1e4 commit cf4a3eb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions plugin/resolvergen/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ func (m *Plugin) generatePerSchema(data *codegen.Data) error {
if o.HasResolvers() {
fn := gqlToResolverName(data.Config.Resolver.Dir(), o.Position.Src.Name)
if files[fn] == nil {
files[fn] = &File{
imports: rewriter.ExistingImports(fn),
}
files[fn] = &File{}
}

rewriter.MarkStructCopied(templates.LcFirst(o.Name) + templates.UcFirst(data.Config.Resolver.Type))
Expand Down Expand Up @@ -120,6 +118,7 @@ func (m *Plugin) generatePerSchema(data *codegen.Data) error {
}

for filename, file := range files {
file.imports = rewriter.ExistingImports(filename)
file.RemainingSource = rewriter.RemainingSource(filename)
}

Expand Down

0 comments on commit cf4a3eb

Please sign in to comment.