Parse string into Date type #807
-
I'm wrapping a REST API into a GraphQL endpoint. The REST API returns a My schema: @ObjectType()
class Widget {
@Field(() => Date)
updatedAt: string
} How should I get GraphQL to parse the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
Date
isDate
, the JSnew Date()
.If you want to treat string as date, just do
@Field(() => String)
or find another GraphQL scalar that accepts strings and numbers as a valid date value.JSON is not capable of transporting
Date
type, it has to be serialized.