add support for custom scalars -- mainly adding proper import machinery

This commit is contained in:
Ben Kraft
2021-04-08 13:07:31 -07:00
parent e68787ad35
commit b4e8316c6a
31 changed files with 283 additions and 89 deletions
+6 -4
View File
@@ -1,7 +1,5 @@
package generate
var unmarshalTemplate = mustTemplate("unmarshal.go.tmpl")
type templateData struct {
// Go type to which the method will be added
Type string
@@ -47,7 +45,11 @@ func (builder *typeBuilder) maybeWriteUnmarshal(fields []field) error {
return nil
}
builder.ImportJSON = true
_, err := builder.addRef("encoding/json.Unmarshal")
if err != nil {
return err
}
builder.WriteString("\n\n")
return unmarshalTemplate.Execute(builder, data)
return builder.execute("unmarshal.go.tmpl", builder, data)
}