In Go, an un-initialized `time.Time` has a value of "0" which the
GraphQL server will accept (as it is not `nil`) and PostgreSQL will
write it to the database. However, the API will afterwards fail to
return the creation date for this ticket, as the value is considered
null, but the ticket type defined to not allow null.
As a first step, prevent clients from creating tickets with the "0"
timestamp by adding a validation that checks the value.
References: https://todo.sr.ht/~sircmpwn/todo.sr.ht/259
Previously, SQL queries in SendEmail would return NULL for participant
types other than 'user' or 'email'. This would panic for participant
types like 'external' since NULL cannot be scanned to a string, which
caused the submitTicket mutation to fail when called with an externalId.
Fix by returning and checking for an empty string instead.
This takes advantages of the improvements to core-go/valid, which allow
us to remove various placeholder errors. This also fixes a few broken
error checks which call err.Error() even when the err is nil, causing a
panic on success.
An input like '#AAAAAAAA' causes hex.Decode to panic. While this
solution does not allow color codes with length 3, those return an error
in hex.Decode either way.
The GraphQL "Subscription" type is special and used for defining
subscription operations. Pick a different name so that GraphQL
parsers don't get confused.
References: https://todo.sr.ht/~sircmpwn/sr.ht/302
Create a new generate.go file which imports github.com/99designs/gqlgen.
This fixes this kind of error because go mod now knows about the
dependency:
/home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/cmd/gen.go:9:2: missing go.sum entry for module providing package github.com/urfave/cli/v2 (imported by github.com/99designs/gqlgen/cmd); to add:
go get github.com/99designs/gqlgen/cmd@v0.13.0
/home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/imports/prune.go:15:2: missing go.sum entry for module providing package golang.org/x/tools/go/ast/astutil (imported by github.com/99designs/gqlgen/internal/imports); to add:
go get github.com/99designs/gqlgen/internal/imports@v0.13.0
/home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/code/packages.go:8:2: missing go.sum entry for module providing package golang.org/x/tools/go/packages (imported by github.com/99designs/gqlgen/internal/code); to add:
go get github.com/99designs/gqlgen/internal/code@v0.13.0
/home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/imports/prune.go:16:2: missing go.sum entry for module providing package golang.org/x/tools/imports (imported by github.com/99designs/gqlgen/internal/imports); to add:
go get github.com/99designs/gqlgen/internal/imports@v0.13.0
graph/resolver.go:7: running "go": exit status 1
missing go.sum entry for module providing package github.com/vektah/dataloaden; to add:
go mod download github.com/vektah/dataloaden
loaders/middleware.go:3: running "./gen": exit status 1