aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/99designs/gqlgen/cmd
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-07-09 13:22:59 +0200
committerMichael Muré <batolettre@gmail.com>2019-07-09 13:22:59 +0200
commit14022953823fc768849b6cc826b05b61a89b7626 (patch)
tree4d4f70ee46b9cc230d6602cb066c697f8a0a4e8e /vendor/github.com/99designs/gqlgen/cmd
parenta5c42b7c11fc082d47027ba5e0dbdeddcc14e62e (diff)
downloadgit-bug-14022953823fc768849b6cc826b05b61a89b7626.tar.gz
graphql: don't use the gqlgen command to generate to avoid pulling urfave/cli
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/cmd')
-rw-r--r--vendor/github.com/99designs/gqlgen/cmd/ambient.go10
-rw-r--r--vendor/github.com/99designs/gqlgen/cmd/gen.go44
-rw-r--r--vendor/github.com/99designs/gqlgen/cmd/init.go144
-rw-r--r--vendor/github.com/99designs/gqlgen/cmd/root.go44
-rw-r--r--vendor/github.com/99designs/gqlgen/cmd/version.go16
5 files changed, 0 insertions, 258 deletions
diff --git a/vendor/github.com/99designs/gqlgen/cmd/ambient.go b/vendor/github.com/99designs/gqlgen/cmd/ambient.go
deleted file mode 100644
index 7838fdf1..00000000
--- a/vendor/github.com/99designs/gqlgen/cmd/ambient.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package cmd
-
-import (
- // Import and ignore the ambient imports listed below so dependency managers
- // don't prune unused code for us. Both lists should be kept in sync.
- _ "github.com/99designs/gqlgen/graphql"
- _ "github.com/99designs/gqlgen/graphql/introspection"
- _ "github.com/vektah/gqlparser"
- _ "github.com/vektah/gqlparser/ast"
-)
diff --git a/vendor/github.com/99designs/gqlgen/cmd/gen.go b/vendor/github.com/99designs/gqlgen/cmd/gen.go
deleted file mode 100644
index c69858b4..00000000
--- a/vendor/github.com/99designs/gqlgen/cmd/gen.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package cmd
-
-import (
- "fmt"
- "os"
-
- "github.com/99designs/gqlgen/api"
- "github.com/99designs/gqlgen/codegen/config"
- "github.com/pkg/errors"
- "github.com/urfave/cli"
-)
-
-var genCmd = cli.Command{
- Name: "generate",
- Usage: "generate a graphql server based on schema",
- Flags: []cli.Flag{
- cli.BoolFlag{Name: "verbose, v", Usage: "show logs"},
- cli.StringFlag{Name: "config, c", Usage: "the config filename"},
- },
- Action: func(ctx *cli.Context) {
- var cfg *config.Config
- var err error
- if configFilename := ctx.String("config"); configFilename != "" {
- cfg, err = config.LoadConfig(configFilename)
- if err != nil {
- fmt.Fprintln(os.Stderr, err.Error())
- os.Exit(1)
- }
- } else {
- 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)
- }
- },
-}
diff --git a/vendor/github.com/99designs/gqlgen/cmd/init.go b/vendor/github.com/99designs/gqlgen/cmd/init.go
deleted file mode 100644
index e07bed97..00000000
--- a/vendor/github.com/99designs/gqlgen/cmd/init.go
+++ /dev/null
@@ -1,144 +0,0 @@
-package cmd
-
-import (
- "bytes"
- "fmt"
- "io/ioutil"
- "os"
- "strings"
-
- "github.com/99designs/gqlgen/api"
- "github.com/99designs/gqlgen/plugin/servergen"
-
- "github.com/99designs/gqlgen/codegen/config"
- "github.com/pkg/errors"
- "github.com/urfave/cli"
- yaml "gopkg.in/yaml.v2"
-)
-
-var configComment = `
-# .gqlgen.yml example
-#
-# Refer to https://gqlgen.com/config/
-# for detailed .gqlgen.yml documentation.
-`
-
-var schemaDefault = `
-# GraphQL schema example
-#
-# https://gqlgen.com/getting-started/
-
-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!
-}
-`
-
-var initCmd = cli.Command{
- Name: "init",
- Usage: "create a new gqlgen project",
- Flags: []cli.Flag{
- cli.BoolFlag{Name: "verbose, v", Usage: "show logs"},
- cli.StringFlag{Name: "config, c", Usage: "the config filename"},
- cli.StringFlag{Name: "server", Usage: "where to write the server stub to", Value: "server/server.go"},
- cli.StringFlag{Name: "schema", Usage: "where to write the schema stub to", Value: "schema.graphql"},
- },
- Action: func(ctx *cli.Context) {
- initSchema(ctx.String("schema"))
- config := initConfig(ctx)
-
- GenerateGraphServer(config, ctx.String("server"))
- },
-}
-
-func GenerateGraphServer(cfg *config.Config, serverFilename string) {
- err := api.Generate(cfg, api.AddPlugin(servergen.New(serverFilename)))
- if err != nil {
- fmt.Fprintln(os.Stderr, err.Error())
- }
-
- fmt.Fprintf(os.Stdout, "Exec \"go run ./%s\" to start GraphQL server\n", serverFilename)
-}
-
-func initConfig(ctx *cli.Context) *config.Config {
- var cfg *config.Config
- var err error
- configFilename := ctx.String("config")
- if configFilename != "" {
- cfg, err = config.LoadConfig(configFilename)
- } else {
- cfg, err = config.LoadConfigFromDefaultLocations()
- }
-
- if cfg != nil {
- fmt.Fprintf(os.Stderr, "init failed: a configuration file already exists\n")
- os.Exit(1)
- }
-
- if !os.IsNotExist(errors.Cause(err)) {
- fmt.Fprintln(os.Stderr, err.Error())
- os.Exit(1)
- }
-
- if configFilename == "" {
- configFilename = "gqlgen.yml"
- }
- cfg = config.DefaultConfig()
-
- cfg.Resolver = config.PackageConfig{
- Filename: "resolver.go",
- Type: "Resolver",
- }
-
- var buf bytes.Buffer
- buf.WriteString(strings.TrimSpace(configComment))
- buf.WriteString("\n\n")
- var b []byte
- b, err = yaml.Marshal(cfg)
- if err != nil {
- fmt.Fprintln(os.Stderr, "unable to marshal yaml: "+err.Error())
- os.Exit(1)
- }
- buf.Write(b)
-
- err = ioutil.WriteFile(configFilename, buf.Bytes(), 0644)
- if err != nil {
- fmt.Fprintln(os.Stderr, "unable to write cfg file: "+err.Error())
- os.Exit(1)
- }
-
- return cfg
-}
-
-func initSchema(schemaFilename string) {
- _, err := os.Stat(schemaFilename)
- if !os.IsNotExist(err) {
- return
- }
-
- err = ioutil.WriteFile(schemaFilename, []byte(strings.TrimSpace(schemaDefault)), 0644)
- if err != nil {
- fmt.Fprintln(os.Stderr, "unable to write schema file: "+err.Error())
- os.Exit(1)
- }
-}
diff --git a/vendor/github.com/99designs/gqlgen/cmd/root.go b/vendor/github.com/99designs/gqlgen/cmd/root.go
deleted file mode 100644
index dc2970ac..00000000
--- a/vendor/github.com/99designs/gqlgen/cmd/root.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package cmd
-
-import (
- "fmt"
- "io/ioutil"
- "log"
- "os"
-
- "github.com/99designs/gqlgen/graphql"
- "github.com/urfave/cli"
-
- // Required since otherwise dep will prune away these unused packages before codegen has a chance to run
- _ "github.com/99designs/gqlgen/handler"
-)
-
-func Execute() {
- app := cli.NewApp()
- app.Name = "gqlgen"
- app.Usage = genCmd.Usage
- app.Description = "This is a library for quickly creating strictly typed graphql servers in golang. See https://gqlgen.com/ for a getting started guide."
- app.HideVersion = true
- app.Flags = genCmd.Flags
- app.Version = graphql.Version
- app.Before = func(context *cli.Context) error {
- if context.Bool("verbose") {
- log.SetFlags(0)
- } else {
- log.SetOutput(ioutil.Discard)
- }
- return nil
- }
-
- app.Action = genCmd.Action
- app.Commands = []cli.Command{
- genCmd,
- initCmd,
- versionCmd,
- }
-
- if err := app.Run(os.Args); err != nil {
- fmt.Fprint(os.Stderr, err.Error())
- os.Exit(1)
- }
-}
diff --git a/vendor/github.com/99designs/gqlgen/cmd/version.go b/vendor/github.com/99designs/gqlgen/cmd/version.go
deleted file mode 100644
index 8b7442d4..00000000
--- a/vendor/github.com/99designs/gqlgen/cmd/version.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package cmd
-
-import (
- "fmt"
-
- "github.com/99designs/gqlgen/graphql"
- "github.com/urfave/cli"
-)
-
-var versionCmd = cli.Command{
- Name: "version",
- Usage: "print the version string",
- Action: func(ctx *cli.Context) {
- fmt.Println(graphql.Version)
- },
-}