I’m learning Go and GraphQL.
I was building a Go environment, but when I ran the gqlgen init
command, I got a message in the terminal bash: gqlgen: command not found
When I ran the gqlgen init command, a message appeared in the terminal.
The command that was executed
$ mkdir with-apollo-api
$ cd with-apollo-api
$ go mod init github.com/yuuu/with-apollo-api
$ go get github.com/99designs/gqlgen
$ go get github.com/rs/cors
# Generate graph/schema.graphqls with gqlgen
$ gqlgen init
2 Answers
You do not have your gqlgen provided as an executable but as an dependecy in project.
To install executable run
go install github.com/99designs/gqlgen
It will install executable and now you can use it
gqlgen init
1
-
1
Depending on the way you installed Go, you might also have to make sure your $PATH includes the
bin/
directory into whichgo install
puts executables.– erik258Oct 2, 2021 at 14:13
Guys if your go generate
command doesnot work for graphql schema updation.
//follow these steps
//add "tools.go" in your current directory & import the module
package tools
import (
_ "github.com/99designs/gqlgen"
)
//than after synchronize your go.mod
root file
go mod tidy
//now you can make changes into your schema by executing this command
{and make sure u deleted your schema.resolver.go
file}
go run github.com/99designs/gqlgen generate
…………………..