Apollo/GraphQL: Field Type to Use for Timestamp?

VikR picture VikR · Dec 11, 2016 · Viewed 11.1k times · Source

I'm storing a value to a postgres field that is of type timestamp with time zone. I was defining the field as an int in my Apollo schema, but I'm getting this error message in the resolver:

column "apptDateTime" is of type timestamp with time zone but expression is of type integer

Looking up GraphQL data types, I don't yet see any type that is cited as corresponding to a field of type timestamp.

What's the correct field type to use in the Apollo schema for a field that is of type timestamp in the database?

Answer

VikR picture VikR · Dec 20, 2016

I got my mutation working that includes a field of type Timestamp with Time Zone. I did it by changing the schema for my apptDateTime field from Int to String, and passing in an ISO string. Sequelize and Postgres took care of changing it into a field of type Timestamp with Time Zone.