models: Painstakingly converted half the model package to a models & repostiry stucture. All binaries are probably dead at this point.
the build failed

This commit is contained in:
2018-09-16 00:13:12 +02:00
parent 2b05d90f4a
commit 0768cfd0bd
38 changed files with 878 additions and 64 deletions
+28
View File
@@ -0,0 +1,28 @@
package scalars
import (
"fmt"
"io"
"time"
"github.com/99designs/gqlgen/graphql"
)
// MarshalDate marshals time into gql Date type
func MarshalDate(t time.Time) graphql.Marshaler {
return graphql.WriterFunc(func(w io.Writer) {
w.Write([]byte(`"` + t.Format(time.RFC3339Nano) + `"`))
})
}
// UnmarshalDate unmarshals time from gql Date type
func UnmarshalDate(v interface{}) (time.Time, error) {
switch v := v.(type) {
case string:
return time.Parse(time.RFC3339Nano, v)
case int:
return time.Unix(0, int64(v)*1000000), nil
default:
return time.Time{}, fmt.Errorf("%T is not a valid time", v)
}
}