-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generated.go does not compile; undefined: gqlparser #1258
Comments
Suspected that there was an alias name mismatch - v2 instead of gqlparser. Could get it working by adding alias in gqlgen/codegen/generated!.gotpl. However, am clueless how it fails only for me. Need help to find this out so that we can use it without the below patch. Probable special scenarios are a) it is used in a bazel based project and b) code generated using gqlgen/api package instead of go run. Patch:
|
[issue #1258] explicitly add gqlparser alias to vektah/gqlparser/v2 import
Closing the issue now that the PR was merged. However, still don't know how only I faced the original issue. |
[issue 99designs#1258] explicitly add gqlparser alias to vektah/gqlparser/v2 import
What happened?
While migrating from v0.10.2 to v0.11.3, generated.go doesn't compile (It used to work absolutely fine under v0.10.2):
/private/var/tmp/_bazel_sateesh/.../sandbox/darwin-sandbox/1531/execroot/__main__/bazel-out/darwin-fastbuild/bin/src/.../generated.go:4521:20: undefined: gqlparser
generated.go does not import
github.com/vektah/gqlparser/v2
. However, generated!.gotpl region uses it -var parsedSchema = gqlparser.MustLoadSchema(sources...)
generated!.gotpl does have
{{ reserveImport "github.com/vektah/gqlparser/v2" }}
.Looking through gqlgen code, there is code to prune -
formatted, err := imports.Prune(filename, b, packages)
. config.Packages.packages does not havegithub.com/vektah/gqlparser/v2
. Couldn't see why gqlparser/v2/ast is present in packages, but not gqlparser/v2.What did you expect?
Expected generated.go to compile; to import the package that is indeed used in the generated!.gotpl region of the file.
Minimal graphql.schema and models to reproduce
versions
gqlgen version
? v0.11.3go version
? v1.14.4The text was updated successfully, but these errors were encountered: