i am trying to add an Date type to my prisma2 schema. I know there is a DateTime type but I am just needing the date. Because I haven't found anything related to Date I would add an Custom input with day, month and year and create then a Date with the time 12:00 (so I have not so much problems with timezones) or a timestamp. I hope you have some better ideas or best practices. best regards and thanks!
Asked
Active
Viewed 294 times
1 Answers
0
create custom date scalar type with nexus. if you're using graphql you need to create a custom scalar like this.
const CustomTime = scalarType({
name: 'CustomTime',
description: 'Consider time as 12 hour time.',
asNexusMethod: 'customTime',
parseValue(value) {
return moment(value, '').format('')
}
})

Harsh Makwana
- 237
- 3
- 13
-
Still didn't get it. I can add the resolver but how I am using it in the schema.prisma file? – user2675468 Feb 25 '21 at 12:13
-
you can't add it in prisma but you can use as input args and then it'll convert it into UTC according to database date and time type. – Harsh Makwana Feb 25 '21 at 13:00