fixes while integrating into webapp

This commit is contained in:
Ben Kraft
2021-03-30 17:53:31 -07:00
parent b125191f99
commit 27ee3c2dbd
9 changed files with 64 additions and 38 deletions
+9 -2
View File
@@ -7,8 +7,8 @@ import (
"sort"
"strings"
"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/formatter"
"github.com/vektah/gqlparser/v2/ast"
"github.com/vektah/gqlparser/v2/formatter"
)
var fileTemplate = mustTemplate("operation.go.tmpl")
@@ -154,6 +154,13 @@ func Generate(config *Config) ([]byte, error) {
return nil, err
}
// TODO: we could also allow this, and generate an empty file with just the
// package-name, if it turns out to be more convenient that way. (As-is,
// we generate a broken file, with just (unused) imports.)
if len(document.Operations) == 0 {
return nil, fmt.Errorf("no queries found in %v", config.Queries)
}
g := newGenerator(config, schema)
for _, op := range document.Operations {
if err = g.addOperation(op); err != nil {