28 lines
539 B
Go
28 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())
|
||
|
}
|