tstor/cmd/generate-graphql-schema/main.go
2024-04-24 20:36:33 +03:00

27 lines
539 B
Go

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