tstor/cmd/generate-graphql-schema/main.go

28 lines
539 B
Go
Raw Normal View History

2024-04-24 17:36:33 +00:00
package main
import (
"fmt"
"log"
"os"
graph "git.kmsign.ru/royalcat/tstor/src/delivery/graphql"
"github.com/vektah/gqlparser/v2/formatter"
)
func main() {
outFile := "schema.graphql"
if len(os.Args) > 1 {
outFile = os.Args[1]
}
file, err := os.OpenFile(outFile, os.O_CREATE|os.O_RDWR|os.O_TRUNC, os.ModePerm)
if err != nil {
log.Panic(fmt.Errorf("Failed to open %s: %w", outFile, err))
}
defer file.Close()
fmt := formatter.NewFormatter(file)
fmt.FormatSchema(graph.NewExecutableSchema(graph.Config{}).Schema())
}