hestia/src/lib/server/pothos/Scalars/Date.ts
2024-12-10 22:52:21 -05:00

15 lines
No EOL
334 B
TypeScript

import dayjs from 'dayjs';
import { builder } from '../builder';
export const Date = builder.scalarType('Date', {
description: 'Date Scalar in ISO format',
serialize: (t) => {
return t.toISOString();
},
parseValue: (date) => {
if (typeof date !== 'string') {
throw new Error('Cyka blyat');
}
return dayjs(date);
}
});