forked from Yamashou/gqlgenc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
34 lines (29 loc) · 778 Bytes
/
main.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
package main
import (
"context"
"fmt"
"os"
"github.com/99designs/gqlgen/api"
"github.com/Yamashou/gqlgenc/clientgen"
"github.com/Yamashou/gqlgenc/clientgenv2"
"github.com/Yamashou/gqlgenc/config"
"github.com/Yamashou/gqlgenc/generator"
)
func main() {
ctx := context.Background()
cfg, err := config.LoadConfigFromDefaultLocations()
if err != nil {
fmt.Fprintf(os.Stderr, "%+v", err.Error())
os.Exit(2)
}
clientGen := api.AddPlugin(clientgen.New(cfg.Query, cfg.Client, cfg.Generate))
if cfg.Generate != nil {
if cfg.Generate.ClientV2 {
clientGen = api.AddPlugin(clientgenv2.New(cfg.Query, cfg.Client, cfg.Generate))
}
}
if err := generator.Generate(ctx, cfg, clientGen); err != nil {
fmt.Fprintf(os.Stderr, "%+v", err.Error())
os.Exit(4)
}
}