gqlgen
gqlgen copied to clipboard
Validation fails when no models are generated
What happened?
I'm using the autobind
feature to bind the types in the API to existing Go types. I have existing types for all the types used in the GraphQL API, which means that gqlgen generate
does not generate any models itself.
This seems to generate a validation failure:
validation failed: packages.Load: -: cannot find module providing package github.com/<user>/<project>/pkg/graph/model: import lookup disabled by -mod=readonly
If I set skip_validation
to true
in the configuration file I no longer get this error when running gqlgen generate
. I'm not really sure what disabling the validation means though. Is the validation something I would ideally want to have enabled?
The error can be reproduced by following the "Quick start" on https://gqlgen.com, and after the initial generation simply copy the generated models to a separate package, and set autobind
to that package. The next generation will then remove the initially generated models, and it will emit the validation failure message as mentioned above.
Is this expected behaviour?
What did you expect?
I would expect the code generation to not generate a validation error.
Versions
-
go run github.com/99designs/gqlgen version
:v0.17.38
-
go version
:go1.21.1 linux/amd64
Some additional information: The same validation error occurs if I manually specify overrides for the types in the models
section of the configuration file instead of using the autobind
feature.
Still an issue after testing with gqlgen v0.17.39
.
Still an issue after testing with gqlgen v0.17.49
.
Seems to be working as expected now, sorry for the noise.