diff --git a/graphql/uuid.go b/graphql/uuid.go index 1bfb7680d5b..e9f22dccdb6 100644 --- a/graphql/uuid.go +++ b/graphql/uuid.go @@ -2,16 +2,15 @@ package graphql import ( "fmt" - "io" - "strconv" "github.com/google/uuid" ) func MarshalUUID(id uuid.UUID) Marshaler { - return WriterFunc(func(w io.Writer) { - _, _ = io.WriteString(w, strconv.Quote(id.String())) - }) + if id == uuid.Nil { + return Null + } + return MarshalString(id.String()) } func UnmarshalUUID(v any) (uuid.UUID, error) { diff --git a/graphql/uuid_test.go b/graphql/uuid_test.go index 3dd7d68ff8c..1d209964497 100644 --- a/graphql/uuid_test.go +++ b/graphql/uuid_test.go @@ -9,7 +9,7 @@ import ( func TestMarshalUUID(t *testing.T) { t.Run("Null Values", func(t *testing.T) { - assert.Equal(t, uuid.Nil, uuid.MustParse("00000000-0000-0000-0000-000000000000")) + assert.Equal(t, "null", m2s(MarshalUUID(uuid.Nil))) }) t.Run("Valid Values", func(t *testing.T) {