gqlgen icon indicating copy to clipboard operation
gqlgen copied to clipboard

GQLGEN fails to generate any output or errors

Open CaptainNickSilver opened this issue 2 years ago • 4 comments

What happened?

After meeting with front end developers who wanted major changes to our GraphQL schema, I took our existing GraphQL golang server, which I've regenerated dozens of times, and ran gqlgen. The gqlgen package deleted the older model/generated.go file, but did not create a new one. If there was a syntax error, I do not know what it is.

After starting this bug report, I realized that I had upgraded go on my machine to the newest version. So I decided to recompile gqlgen: I used "go run" to run gqlgen and it told me I needed to go get some dependencies from 99designs, which I got.

Then I reissued the go run gqlgen version command, which returned the newest version number. However, this made zero difference on the results of the gqlgen command.

The newest version of go is running

What did you expect?

There are zero errors and zero messages. the previous "generated.go" has been deleted. No replacement was generated.
Even --verbose generates no output

Minimal graphql.schema and models to reproduce

I reduced the schema down to "trivial" and nothing is generated. The problem does not appear to be in the schema changes

GraphQL schema

type tag { tagName: String votes: Int }

type content_short { contentId: ID! title: String contenttype: String # type of the content record tags: [tag] siteurl: String # full URL of the content page for this video or gallery filename: String! # full url to the cdn location where the video image is stored. Empty string if gallery embed: String! # full url of the embedded video for iframe uses thumbnail: String # full url to the cdn location where the thumbnail image is stored mobile: String # full url to the cdn location where the mobile video is stored. Empty string if gallery status: String # human readable status to interpret the enabled and approved codes isQuality: Int # boolean flag if this is considered a high quality image isPremium: Int # boolean flag if this is a protected (premium) image. Only admins and paid users can see premium images likeCount: Int # raw number of upvotes, favorites, or shares rating: Int # integer percentage of upvotes to downvotes. example: 75 is 3 upvotes to every 1 downvote background_id: ID # if the content item should have a specific content item as a background commentCount: Int # total number of comments viewcount: Int # total number of views }

Here is the gqlgen.yml. I changed nothing from the days where gqlgen was working (not that long ago)

schema:

  • graph/*.graphqls

exec: filename: graph/generated/generated.go package: generated

model: filename: graph/model/models_gen.go package: model

resolver: layout: follow-schema dir: graph package: graph

autobind:

  • "github.com/captainnicksilver/graphql-in-go/graph/model"

models: ID: model: - github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 Int: model: - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32

versions

  • go run github.com/99designs/gqlgen version? v0.17.10
  • go version? go version go1.19 windows/amd64

CaptainNickSilver avatar Aug 28 '22 17:08 CaptainNickSilver

I had a similar problem with one of my project.

I tried the below three steps again and it worked fine. image

make sure your go get for gqlgen has -d

kunalrsagar avatar Aug 31 '22 14:08 kunalrsagar

This pulls the most recent version of 99designs which I did. I rebuilt the executable using the newest version of go (1.18). It had no effect. Running gqlgen produces no output, deletes the generated files, and craps out. No messages of any kind describing why.

CaptainNickSilver avatar Sep 05 '22 02:09 CaptainNickSilver

In my case I am using go 1.8.3. When I updated gqlgen to the latest version, everything works fine.

ralvescosta avatar Sep 05 '22 18:09 ralvescosta

One of the devs on my team has a similar issue. We all build fine, but he can't build on his machine. No errors, just fails to produce anything. I just forked to try and add error logs so we can troubleshoot. Any recommendations on where to look first would be helpful.

dsgipe avatar Sep 15 '22 15:09 dsgipe

Found and fixed. It was not what I expected. In order to find this, I put the gqlgen under the debugger in vscode. The failure was in one of the Go Library modules (packages.load()) that is used to evaluate a go program. This is really deep stuff and the error was a flat out panic. I looked up the code online and the code in my debugger and... the code didn't match. I WAS NOT RUNNING THE CURRENT PACKAGE.

Turns out I had upgraded to Go 1.19 in August but the Windows Installer does not upgrade the go x/tools files that get installed when you go get the 99designs code.

What I did to fix this (this is on Windows. I have no idea if this occurs on Linux).

Change directory to my GOPATH directory cd %GOPATH%\src\golang.org\x

then I updated all the dependencies from that directory on down. go get -u ./...

then just to be sure, I also re-requested gqlgen with the -u parameter go get -u github.com/99designs/gqlgen

I recompiled gqlgen

cd %GOPATH%\src\github.com\99designs\gqlgen
go build

After that, the gqlgen program worked. It's possible that one of the steps in this list is extra... but this worked for me. I hope it helps you as well

CaptainNickSilver avatar Sep 26 '22 06:09 CaptainNickSilver

I get this error when running model gen

go run gen/modelgen/*.go no version found matching 12.6.0 panic: no version found matching 12.6.0

jacmacmod avatar Sep 28 '22 10:09 jacmacmod

I should have marked this as closed. See my prior comment where I discuss how to fix this. The problem was that I had upgraded the version of Go on my developer workstation but that the upgrade process did not pull the current library for the version of Go that I was using. See above

CaptainNickSilver avatar Oct 31 '22 08:10 CaptainNickSilver