aboutsummaryrefslogtreecommitdiffstats
path: root/api/graphql/gen_graphql.go
blob: 19c5f1e3d81bb219d806bcb3b1f7de31dfd767e6 (plain) (blame)
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
//go:build ignore

package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"os"

	"github.com/99designs/gqlgen/api"
	"github.com/99designs/gqlgen/codegen/config"
	"github.com/pkg/errors"
)

func main() {
	fmt.Println("Generating graphql code ...")

	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)
	}
}