Go gqlgen command not found occurs

Go gqlgen command not found occurs


0

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
2


0

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 which go install puts executables.

    – erik258

    Oct 2, 2021 at 14:13



0

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

…………………..

New contributor

Shubham Mishra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



Leave a Reply

Your email address will not be published. Required fields are marked *