-
Notifications
You must be signed in to change notification settings - Fork 0
/
gencli.go
35 lines (30 loc) · 936 Bytes
/
gencli.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"fmt"
"github.com/99designs/gqlgen/api"
"github.com/99designs/gqlgen/codegen/config"
"github.com/Yamashou/gqlgenc/clientgenv2"
"os"
)
func main() {
fmt.Printf("Generating localui...\n")
packageName := "localui"
clientOutputFilePath := "./gql_client_gen.go"
queryFilePaths := []string{"./graphql/*.graphql"}
cfg, err := config.LoadConfigFromDefaultLocations()
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "failed to load config: %+v\n", err)
os.Exit(2)
}
clientConfig := config.PackageConfig{Filename: clientOutputFilePath, Package: packageName}
if err = clientConfig.Check(); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "failed to load generated file path: %+v\n", err)
os.Exit(2)
}
clientPlugin := clientgenv2.New(queryFilePaths, clientConfig, nil)
err = api.Generate(cfg, api.AddPlugin(clientPlugin))
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "%+v\n", err)
os.Exit(4)
}
}