Open adrianlungu opened 1 year ago
I just ran into this too, thanks for documenting it. Was there an actual work around found? You said you imported the subpackage but I'm not sure exactly where you imported it to.
@bradhe yes, I have a cmd/generate/main.go
file in which I have the code that loads the gqlgen codegen config, and calls api.Generate
; in there, I added the following import
_ "github.com/99designs/gqlgen/graphql/introspection"
to make sure that the code will run.
What happened?
When using
-mod=vendor
, the project should properly account for imports; however, one of the imports is not added to the mod file due to it being specified only in the go template file resulting in:The offending file is
github.com/99designs/gqlgen/codegen/root_.gotpl
where{{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }}
is reserved but not imported explicitly anywhere.Using
_ "github.com/99designs/gqlgen/graphql/introspection"
fixes the issue but this should probably be included in the project and not in projects importing the package.Keep in mind this is in a
plugin
project that imports gqlgen.What did you expect?
Code generation to work successfully after running
go mod vendor
andgo mod tidy
invendor mode
via-mod=vendor
set inGOFLAGS
.Minimal graphql.schema and models to reproduce
N/A
versions
go run github.com/99designs/gqlgen version
?github.com/99designs/gqlgen v0.17.34
go version
?go version go1.20.5 darwin/arm64