New broken prelude.resolvers.go file with v0.17.0
What happened?
Since v0.17.0, running gqlgen throws some errors:
Error: validation failed: packages.Load: <repo>/graph/prelude.resolvers.go:23:41: __SchemaResolver not exported by package generated
Error: <repo>/graph/prelude.resolvers.go:26:39: __TypeResolver not exported by package generated
It generates a prelude.resolvers.go file that is not generated in v0.16.0, which seems to have some errors in it.
What did you expect?
gqlgen v0.17.0 generates the same proper files as gqlgen v0.16.0, without errors.
Minimal graphql.schema and models to reproduce
type Object {
id: ID!
text: String!
}
input NewObject {
text: String!
}
type Mutation {
createObject(input: NewObject!): Object!
}
versions
-
go run github.com/99designs/gqlgen version:v0.17.0(latest as of writing this issue) -
go version:go version go1.16.1 linux/amd64
@nathani-axis Could you share me your gqlgen.yml and your go.mod? (I supported around prelude maybe I can understand why happened) Thanks
Probably this link help you https://github.com/99designs/gqlgen/discussions/2018
I think we can close this. Please @nathani-axis speak with us...
I'm on the latest version from master for gqlparser and gqlgen and still have this github.com/vektah/gqlparser/v2 v2.4.2-0.20220315005344-931cd7644eee github.com/99designs/gqlgen v0.17.2-0.20220316114301-87fc5f22e8fb
~~I have the same problems. Doesn't work for anyone at our org at the moment.~~ edit: apologies, was easily resolved using comment abovego get -d github.com/99designs/gqlgen@master @frederikhors
Can you please create a MINIMAL reproduction? This is crazy. Here no problems at all!
@frederikhors I figured it out, errors are confusing, in enums if your are using autobinding and didn't implement marshalling and unmarshalling generated code is broken with such weird error.
It seems to be tough to make minimal reproduction since I have huge package with lots of types, but once I removed autobind and did manual binding it works ok
Ok. We are not using the TRAGIC autobind feature here.
What can we do to improve errors?
I guess we need somehow detect that fields that we are binding are implementing marshalling methods.
run go get github.com/vektah/gqlparser/[email protected]
I just encountered something really similar when upgrading from 0.17.38 to 0.17.39. I had to back out the upgrade because I didn't have time to debug.
Hey, I ran into this issue when I upgraded entgql to use v0.17.39.
Edit: I'm wrong, this PR causes the issue on v0.17.39: https://github.com/99designs/gqlgen/pull/2812
Edit: In our case, we already have the type Field, which wasn't binding to the Field interface of GQL. The Field interface is from schema github.com/99designs/gqlgen/graphql/introspection.Field. After that PR, the logic was changed and it bound to our type and generated a lot of incorrect interfaces.
Edit: Link a solution https://github.com/99designs/gqlgen/issues/227#issuecomment-1787159496
I had the same issue, and I wasn't able to upgrade the gqlgen version anymore. All >= v0.17.39 versions were broken for me and getting weird interfaces such as __Field() __FieldResolver and __Type() __TypeResolver.
Thanks to the #227 (comment), adding the github.com/99designs/gqlgen/graphql/introspection as a first autobind to gqlgen.yml file apparently is the only fix for now.
autobind:
- github.com/99designs/gqlgen/graphql/introspection