import { GraphQLScalarType, Kind } from 'graphql';
export const DateType = new GraphQLScalarType({
    name: 'Date',
    description: 'Date custom scalar type',
    parseValue: (value) => {
        if (value === 0) {
            return null;
        }
        return new Date(value);
    },
    serialize: (value) => {
        // This is the object received back from the DB
        if (value === 0) {
            return null;
        }
        return new Date(value);
    },
    parseLiteral: (ast) => {
        if (ast.kind === Kind.STRING) {
            if (ast.value === '0') {
                return null;
            }
            return (new Date(ast.value)).getTime();
        }
        return null;
    },
});
//# sourceMappingURL=DateType.js.map