generates something mostly plausiblegit add .

This commit is contained in:
Ben Kraft
2019-12-23 23:22:19 -05:00
parent 7a20e2ae74
commit e8b5ccbcda
8 changed files with 23487 additions and 17 deletions
+11 -2
View File
@@ -6,6 +6,8 @@ import (
"io/ioutil"
"net/http"
"strings"
"github.com/vektah/gqlparser/gqlerror"
)
{{range .Operations}}
@@ -33,12 +35,19 @@ func {{.OperationName}}(ctx context.Context) (*{{.ResponseName}}, error) {
return nil, err
}
retval := {{.ResponseName}}{}
var retval struct {
Data {{.ResponseName}} `json:"data"`
Errors gqlerror.List `json:"errors"`
}
err = json.Unmarshal(body, &retval)
if err != nil {
return nil, err
}
return &retval, nil
if len(retval.Errors) > 0 {
return nil, retval.Errors
}
return &retval.Data, nil
}
{{end}}