Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Fails Compile outside of GOPATH #547

Closed
bheatwole opened this issue Feb 14, 2019 · 1 comment
Closed

Project Fails Compile outside of GOPATH #547

bheatwole opened this issue Feb 14, 2019 · 1 comment

Comments

@bheatwole
Copy link

Expected Behaviour

If a project is created outside of the GOPATH and 'go mod init' is used, gqlgen should work.

Actual Behavior

gqlgen must be run from inside your $GOPATH
exit status 1

Steps to reproduce

aaaf94315952:~$ go version
go version go1.11.5 linux/amd64
aaaf94315952:~$ export GOPATH=
aaaf94315952:~$ mkdir -p ~/gqlgen-todos
aaaf94315952:~$ cd gqlgen-todos/
aaaf94315952:~/gqlgen-todos$ go mod init github.com/yourname/gqlgen-todos
go: creating new go.mod: module github.com/yourname/gqlgen-todos
aaaf94315952:~/gqlgen-todos$ mkdir scripts
aaaf94315952:~/gqlgen-todos$ cat > scripts/gqlgen.go << EOF
// +build ignore

package main

import "github.com/99designs/gqlgen/cmd"

func main() {
  cmd.Execute()
}
EOF
aaaf94315952:~/gqlgen-todos$ cat > schema.graphql << EOF
type Todo {
  id: ID!
  text: String!
  done: Boolean!
  user: User!
}

type User {
  id: ID!
  name: String!
}

type Query {
  todos: [Todo!]!
}

input NewTodo {
  text: String!
  userId: String!
}

type Mutation {
  createTodo(input: NewTodo!): Todo!
}
EOF
aaaf94315952:~/gqlgen-todos$ go run scripts/gqlgen.go init
go: finding github.com/99designs/gqlgen/cmd latest
go: finding github.com/vektah/gqlparser/ast latest
go: finding github.com/vektah/gqlparser/gqlerror latest
go: finding github.com/vektah/gqlparser/validator latest
go: finding github.com/vektah/gqlparser/parser latest
go: finding golang.org/x/tools/go/loader latest
go: finding golang.org/x/tools/go/ast/astutil latest
go: finding golang.org/x/tools/imports latest
go: finding golang.org/x/tools/go/ast latest
go: finding golang.org/x/tools/go latest
go: finding golang.org/x/tools latest
NAME:
   gqlgen - generate a graphql server based on schema

USAGE:
   gqlgen [global options] command [command options] [arguments...]

DESCRIPTION:
   This is a library for quickly creating strictly typed graphql servers in golang. See https://gqlgen.com/ for a getting started guide.

COMMANDS:
     generate  generate a graphql server based on schema
     init      create a new gqlgen project
     version   print the version string
     help, h   Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --verbose, -v             show logs
   --config value, -c value  the config filename
   --help, -h                show help
gqlgen must be run from inside your $GOPATH
exit status 1

Pull Request Coming

I am working on a pull request that fixes this issue

@vektah
Copy link
Collaborator

vektah commented Feb 17, 2019

dupe of #226

@vektah vektah closed this as completed Feb 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants