-
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
Federation plugin does not import autobind and generated models #2326
Comments
bump |
erankor
added a commit
to erankor/gqlgen
that referenced
this issue
Mar 27, 2023
fixes 99designs#2326 - when using `@entityResolver(multi: true)` the InputType of the entity resolver may be in a different package (usually `model`). The fix is to pull the types.Type of the resolver input, and use templates.CurrentImports.LookupType in order to render it correctly (possibly adding another import)
StevenACoffman
pushed a commit
that referenced
this issue
Mar 28, 2023
* EntityResolver input type fix fixes #2326 - when using `@entityResolver(multi: true)` the InputType of the entity resolver may be in a different package (usually `model`). The fix is to pull the types.Type of the resolver input, and use templates.CurrentImports.LookupType in order to render it correctly (possibly adding another import) * entityResolver input type fix: update tests change testdata/entityresolver/gqlgen.yml to use a dedicated package for the model (as in the default sample yml), and run go generate. before the input type fix, generation fails with errors like - plugin/federation/testdata/entityresolver/generated/federation.go:338:17: undeclared name: MultiHelloByNamesInput plugin/federation/testdata/entityresolver/generated/federation.go:354:21: undeclared name: MultiHelloMultipleRequiresByNamesInput plugin/federation/testdata/entityresolver/generated/federation.go:362:17: undeclared name: MultiHelloMultipleRequiresByNamesInput
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happened?
When using the federation plugin with the
@entityResolver(multi: true)
directive, the entity's input struct is created in the generated models file.If the generated models are located not in the same package as the federation package, we get an undeclared name error, as the generated federation file does not import the models.
What did you expect?
When generating the federation file, it should include the generated models import and the autobind imports if needed.
Minimal graphql.schema and models to reproduce
Schema:
Generated input struct in models_gen.go:
versions
go run github.com/99designs/gqlgen version
v0.17.13go version
1.17.9The text was updated successfully, but these errors were encountered: