You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GraphqlTime type from graphql-iso-date is not compatible with Sequelize time type.
The problem is that when graphql parses a time type it actually creates a Date with the current day and the time provided by the user. The following code is taken from the graphql-iso-date library
// Parses an RFC 3339 compliant time-string into a Date.
// It does this by combining the current date with the time-string
// to create a new Date instance.
//
// Example:
// Suppose the current date is 2016-01-01, then
// parseTime('11:00:12Z') parses to a Date corresponding to
// 2016-01-01T11:00:12Z.
export const parseTime = (time: string): Date => {
const currentDateString = new Date().toISOString()
return new Date(currentDateString.substr(0, currentDateString.indexOf('T') + 1) + time)
}
When we pass to sequelize a time already parsed by graphql, then it will throw an error like this one:
SequelizeDatabaseError: invalid input syntax for type time: "2020-07-29T10:15:30.000+00:00"
And the error is because Sequelize expects only to receive a time type such as 10:15:30Z.
The curious thing is that the same happens for Date type, graphql parses and automatically add the time extra info, but sequelize is capable to extract only the Date.
The text was updated successfully, but these errors were encountered:
It appears the library we use is buggy. I don't see where adding a date to a time is correct behavior. As the new repository is doing the same, let's not use that either. Luckily it seems to be easy to define and implement home rolled scalar types like Date, DateTime, Time, Aliens
For now remove Time from our global schema, because it appears wrong (to @asishallab) that a ISO-Time is converted to an instance with a Date. The latter actually causes trouble when being fed into Sequelize.
GraphqlTime type from
graphql-iso-date
is not compatible with Sequelize time type.The problem is that when graphql parses a time type it actually creates a Date with the current day and the time provided by the user. The following code is taken from the graphql-iso-date library
When we pass to sequelize a time already parsed by graphql, then it will throw an error like this one:
And the error is because Sequelize expects only to receive a time type such as
10:15:30Z
.The curious thing is that the same happens for Date type, graphql parses and automatically add the time extra info, but sequelize is capable to extract only the Date.
The text was updated successfully, but these errors were encountered: