From e90d10895bd124a6519d08e4c18fa49a4f592b5f Mon Sep 17 00:00:00 2001 From: Rik Nauta Date: Fri, 26 May 2017 13:49:42 +0200 Subject: [PATCH] allow custom types as input arguments --- internal/validation/validation.go | 3 +++ time.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/internal/validation/validation.go b/internal/validation/validation.go index ad11c519420..f978d17473e 100644 --- a/internal/validation/validation.go +++ b/internal/validation/validation.go @@ -607,6 +607,9 @@ func validateBasicLit(v *common.BasicLit, t common.Type) bool { return v.Type == scanner.Ident && (v.Text == "true" || v.Text == "false") case "ID": return v.Type == scanner.Int || v.Type == scanner.String + default: + //TODO: Type-check against expected type by Unmarshalling + return true } case *schema.Enum: diff --git a/time.go b/time.go index da8ec9a5c07..05c616d0fcb 100644 --- a/time.go +++ b/time.go @@ -27,6 +27,9 @@ func (t *Time) UnmarshalGraphQL(input interface{}) error { case int: t.Time = time.Unix(int64(input), 0) return nil + case float64: + t.Time = time.Unix(int64(input), 0) + return nil default: return fmt.Errorf("wrong type") }