gqlgen icon indicating copy to clipboard operation
gqlgen copied to clipboard

New broken prelude.resolvers.go file with v0.17.0

Open nathani-work opened this issue 4 years ago • 22 comments

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-work avatar Mar 02 '22 12:03 nathani-work

@nathani-axis Could you share me your gqlgen.yml and your go.mod? (I supported around prelude maybe I can understand why happened) Thanks

Code-Hex avatar Mar 02 '22 12:03 Code-Hex

Probably this link help you https://github.com/99designs/gqlgen/discussions/2018

Code-Hex avatar Mar 07 '22 01:03 Code-Hex

I think we can close this. Please @nathani-axis speak with us...

frederikhors avatar Mar 07 '22 08:03 frederikhors

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

image

zmitry avatar Mar 16 '22 12:03 zmitry

~~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

NickDiPreta avatar Mar 16 '22 17:03 NickDiPreta

Can you please create a MINIMAL reproduction? This is crazy. Here no problems at all!

frederikhors avatar Mar 16 '22 17:03 frederikhors

@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.

zmitry avatar Mar 16 '22 19:03 zmitry

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

zmitry avatar Mar 16 '22 19:03 zmitry

Ok. We are not using the TRAGIC autobind feature here.

What can we do to improve errors?

frederikhors avatar Mar 16 '22 19:03 frederikhors

I guess we need somehow detect that fields that we are binding are implementing marshalling methods.

zmitry avatar Mar 16 '22 20:03 zmitry

run go get github.com/vektah/gqlparser/[email protected]

oneuid avatar Mar 17 '22 08:03 oneuid

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.

sdemjanenko avatar Oct 13 '23 16:10 sdemjanenko

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

giautm avatar Feb 08 '24 18:02 giautm

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

gurkanguray avatar Feb 22 '24 23:02 gurkanguray