Peter Kurfer
9ea9a8f658
Some checks failed
Go build / build (push) Failing after 1m58s
- setup ent scheme - add command to create users - document API - add helpers to create migrations - add command to run migrations - add basic compose file
24 lines
456 B
Go
24 lines
456 B
Go
package uuidgql
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"strconv"
|
|
|
|
"github.com/99designs/gqlgen/graphql"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func MarshalUUID(u uuid.UUID) graphql.Marshaler {
|
|
return graphql.WriterFunc(func(w io.Writer) {
|
|
_, _ = io.WriteString(w, strconv.Quote(u.String()))
|
|
})
|
|
}
|
|
|
|
func UnmarshalUUID(v interface{}) (u uuid.UUID, err error) {
|
|
s, ok := v.(string)
|
|
if !ok {
|
|
return u, fmt.Errorf("invalid type %T, expect string", v)
|
|
}
|
|
return uuid.Parse(s)
|
|
}
|