From cf4a3eb455da1c482c20418deceeb44698a7f5bc Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 4 Feb 2020 21:43:57 +1100 Subject: [PATCH] keep imports when scattering resolvers between files --- plugin/resolvergen/resolver.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugin/resolvergen/resolver.go b/plugin/resolvergen/resolver.go index 541d1a64707..5fda546cb46 100644 --- a/plugin/resolvergen/resolver.go +++ b/plugin/resolvergen/resolver.go @@ -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)) @@ -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) }