diff options
author | Michael Muré <batolettre@gmail.com> | 2019-07-09 13:22:59 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2019-07-09 13:22:59 +0200 |
commit | 14022953823fc768849b6cc826b05b61a89b7626 (patch) | |
tree | 4d4f70ee46b9cc230d6602cb066c697f8a0a4e8e /graphql/gen_graphql.go | |
parent | a5c42b7c11fc082d47027ba5e0dbdeddcc14e62e (diff) | |
download | git-bug-14022953823fc768849b6cc826b05b61a89b7626.tar.gz |
graphql: don't use the gqlgen command to generate to avoid pulling urfave/cli
Diffstat (limited to 'graphql/gen_graphql.go')
-rw-r--r-- | graphql/gen_graphql.go | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/graphql/gen_graphql.go b/graphql/gen_graphql.go index 41fa71a9..47f2c458 100644 --- a/graphql/gen_graphql.go +++ b/graphql/gen_graphql.go @@ -4,12 +4,30 @@ package main import ( "fmt" + "io/ioutil" + "log" + "os" - "github.com/99designs/gqlgen/cmd" + "github.com/99designs/gqlgen/api" + "github.com/99designs/gqlgen/codegen/config" + "github.com/pkg/errors" ) func main() { fmt.Println("Generating graphql code ...") - cmd.Execute() + log.SetOutput(ioutil.Discard) + + cfg, err := config.LoadConfigFromDefaultLocations() + if os.IsNotExist(errors.Cause(err)) { + cfg = config.DefaultConfig() + } else if err != nil { + _, _ = fmt.Fprintln(os.Stderr, err.Error()) + os.Exit(2) + } + + if err = api.Generate(cfg); err != nil { + _, _ = fmt.Fprintln(os.Stderr, err.Error()) + os.Exit(3) + } } |