I attempted to build my project with the following imports:
github.com/99designs/gqlgen
github.com/99designs/gqlgen/graphql/handler
github.com/99designs/gqlgen/graphql/playground
Received the following error upon running go build:
cannot load github.com/99designs/gqlgen/graphql/handler: module github.com/99designs/gqlgen@latest found (v0.10.2), but does not contain package github.com/99designs/gqlgen/graphql/handler
The packages to be found
N/A
gqlgen version?v0.10.2go version?go1.13.5 linux/amd64I believe changing the import statement to import {module name}/{package name}, where module name is github.com/99designs/gqlgen resolves the issue. e.g.
FROM
import "github.com/99designs/gqlgen/graphql/handler"
TO
import "github.com/99designs/gqlgen/handler"
The examples might be out of date
It actually seems like import "github.com/99designs/gqlgen/handler" does not import the same package as import "github.com/99designs/gqlgen/graphql/handler" (which still does not work for me). I cannot find the New function. It seems like import "github.com/99designs/gqlgen/handler" is deprecated.
I was able to replicate this error in go playground which leads me to believe it is not my local setup.
package main
import (
"fmt"
"github.com/99designs/gqlgen"
"github.com/99designs/gqlgen/graphql/handler"
)
func main() {
fmt.Println("Hello, playground")
}
OUTPUT:
go: finding github.com/99designs/gqlgen v0.10.2
go: downloading github.com/99designs/gqlgen v0.10.2
go: extracting github.com/99designs/gqlgen v0.10.2
go: downloading gopkg.in/yaml.v2 v2.2.2
go: downloading github.com/vektah/gqlparser v1.2.0
go: downloading github.com/pkg/errors v0.8.1
go: downloading github.com/hashicorp/golang-lru v0.5.0
go: downloading github.com/gorilla/websocket v1.2.0
go: downloading golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd
go: extracting github.com/pkg/errors v0.8.1
go: downloading github.com/urfave/cli v1.20.0
go: extracting github.com/gorilla/websocket v1.2.0
go: extracting github.com/vektah/gqlparser v1.2.0
go: extracting github.com/hashicorp/golang-lru v0.5.0
go: extracting gopkg.in/yaml.v2 v2.2.2
go: downloading github.com/agnivade/levenshtein v1.0.1
go: extracting github.com/urfave/cli v1.20.0
go: extracting github.com/agnivade/levenshtein v1.0.1
go: extracting golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd
go: finding golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/vektah/gqlparser v1.2.0
go: finding github.com/agnivade/levenshtein v1.0.1
go: finding gopkg.in/yaml.v2 v2.2.2
go: finding github.com/gorilla/websocket v1.2.0
go: finding github.com/hashicorp/golang-lru v0.5.0
go: finding github.com/urfave/cli v1.20.0
build command-line-arguments: cannot load github.com/99designs/gqlgen/graphql/handler: module github.com/99designs/gqlgen@latest found (v0.10.2), but does not contain package github.com/99designs/gqlgen/graphql/handler
Go build failed.
I have also tested with go 1.12.9 and replicated the same thing
go get is not pulling the latest version of the code from github?
This has fixed the problem for me:
go get -u github.com/99designs/gqlgen@f869f5a85385745d5854daaa25eab5571b04b245
(f869f5a85385745d5854daaa25eab5571b04b245 is the latest commit as of this moment)
@fwojciec thank you for the advice, that seemed to have worked. I'm going to keep this issue open however since the go get should be pulling the latest version I believe.
I've run into the same :) Thanks for filing the report -- it was helpful in helping me identify the issue!
In case anyone else runs into this --:
go get command basically fetches the last tagged version of the repo by default (which makes sense). The current tagged version for the gqlgen repo is 0.10.2, while the changed package structure in the examples seems to be work in progress for the 0.11 release (as described in the docs).
In other words -- as soon as the new version is officially released and tagged everything should work correctly and the workaround above shouldn't be required anymore.
Sorry for the confusion, The docs now show the stable version by default with the master docs available at https://gqlgen.com/master/.
Most helpful comment
go get is not pulling the latest version of the code from github?
This has fixed the problem for me:
go get -u github.com/99designs/gqlgen@f869f5a85385745d5854daaa25eab5571b04b245(f869f5a85385745d5854daaa25eab5571b04b245 is the latest commit as of this moment)