gqlgen icon indicating copy to clipboard operation
gqlgen copied to clipboard

Validation fails when no models are generated

Open christeredvartsen opened this issue 1 year ago • 2 comments

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

christeredvartsen avatar Sep 24 '23 14:09 christeredvartsen

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.

christeredvartsen avatar Sep 24 '23 16:09 christeredvartsen

Still an issue after testing with gqlgen v0.17.39.

christeredvartsen avatar Oct 23 '23 18:10 christeredvartsen

Still an issue after testing with gqlgen v0.17.49.

christeredvartsen avatar Jul 03 '24 14:07 christeredvartsen

Seems to be working as expected now, sorry for the noise.

christeredvartsen avatar Jul 04 '24 07:07 christeredvartsen