I'm learning Golang 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
CodePudding user response:
Have you checked the getting started? https://gqlgen.com/getting-started/
Setup Project
Create a directory for your project, and initialise it as a Go Module:
$ mkdir gqlgen-todos
$ cd gqlgen-todos
$ go mod init github.com/[username]/gqlgen-todos
$ go get github.com/99designs/gqlgen
Building the server Create the project skeleton
$ go run github.com/99designs/gqlgen init
What I say is: you can't run gqlgen
command if you don't install first. Bash doesn't know it.
Another way: install gqlgen
with go
command:
go install github.com/99designs/gqlgen@latest
CodePudding user response:
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