gqlgen: Following the getting started fails with go1.18beta2

What happened?

Trying to follow the getting started fails at step go run github.com/99designs/gqlgen init.

Adding the --verbose flag produces the following error message:

internal error: package "github.com/vektah/gqlparser/v2/ast" without types was imported from "github.com/99designs/gqlgen/graphql/introspection"

Further executions of the generate command produce the same error.

What did you expect?

Being able to go through the getting started without errors.

Minimal graphql.schema and models to reproduce

N/A

versions

  • gqlgen v0.16.0
  • go v1.18beta2
  • go modules

Complete logs (reproduced in a docker container)

$ docker container run -it --rm golang:1.18-rc bash
root@bf9534c22485:/go# mkdir example
root@bf9534c22485:/go# cd example
root@bf9534c22485:/go# go mod init example
go: creating new go.mod: module example
root@bf9534c22485:/go/example# printf '// +build tools\npackage tools\nimport _ "github.com/99designs/gqlgen"' | gofmt > tools.go
root@bf9534c22485:/go# go mod tidy
go: finding module for package github.com/99designs/gqlgen
go: downloading github.com/99designs/gqlgen v0.16.0
go: found github.com/99designs/gqlgen in github.com/99designs/gqlgen v0.16.0
go: downloading github.com/matryer/moq v0.2.3
go: downloading github.com/urfave/cli/v2 v2.3.0
go: downloading github.com/vektah/gqlparser/v2 v2.2.0
go: downloading github.com/stretchr/testify v1.4.0
go: downloading github.com/gorilla/websocket v1.4.2
go: downloading golang.org/x/tools v0.1.5
go: downloading gopkg.in/yaml.v2 v2.2.4
go: downloading github.com/hashicorp/golang-lru v0.5.0
go: downloading github.com/mitchellh/mapstructure v1.2.3
go: downloading github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883
go: downloading github.com/agnivade/levenshtein v1.1.0
go: downloading gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading github.com/sergi/go-diff v1.1.0
go: downloading github.com/kr/pretty v0.1.0
go: downloading github.com/kr/text v0.1.0
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.1
go: downloading github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48
go: downloading github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0
go: downloading github.com/russross/blackfriday/v2 v2.1.0
go: downloading golang.org/x/mod v0.4.2
go: downloading golang.org/x/sys v0.0.0-20210510120138-977fb7262007
go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
root@bf9534c22485:/go/example# go run github.com/99designs/gqlgen --verbose init
Creating gqlgen.yml
Creating graph/schema.graphqls
Creating server.go
Generating...
internal error: package "github.com/vektah/gqlparser/v2/ast" without types was imported from "github.com/99designs/gqlgen/graphql/introspection"
exit status 1
root@bf9534c22485:/go/example# go run github.com/99designs/gqlgen --verbose generate
internal error: package "github.com/vektah/gqlparser/v2/ast" without types was imported from "github.com/99designs/gqlgen/graphql/introspection"
exit status 1

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 21 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Hello I’m running the tutorial and running gqlgen v0.17.2 and go1.18 windows/amd64 it appears that the command ‘go run github.com/99designs/gqlgen init’ causes this same issue again

BTW, I cut a new gqlgen v0.17.2 release now that Go 1.18 is out and I didn’t see any reports of issues with the fix.

The Unexpected package creation during export data loading bug appears to be an issue with golang.org/x/tools as well.

It has been reported here.

The original issue with v0.16 can be solved by upgrading golang.org/x/tools to v0.1.8+.

As for the other issue, you can reproduce it using this: https://github.com/Desuuuu/gqlgen-issue

Adding the NeedDeps flag as mentionned in https://github.com/99designs/gqlgen/issues/1961#issuecomment-1035482833 does seem to fix the problem.

The problem reported by this issue is fixed in gqlgen v0.17, so I’m closing this.

However I’m still having an issue with generate returning the error: Unexpected package creation during export data loading on a project I’m writing using go1.18, I will open another issue.

Please can you monitor this for us?

No problem.