mirror of
https://github.com/strapi/strapi.git
synced 2025-07-27 19:10:01 +00:00
21 lines
629 B
JavaScript
21 lines
629 B
JavaScript
![]() |
'use strict';
|
||
|
|
||
|
const { GraphQLDate } = require('graphql-iso-date/dist');
|
||
|
|
||
|
const parseAndCast = parseFn => (...args) => {
|
||
|
const parsedValue = parseFn(...args);
|
||
|
|
||
|
if (parsedValue instanceof Date) {
|
||
|
return parsedValue.toISOString().split('T')[0];
|
||
|
}
|
||
|
|
||
|
return parsedValue;
|
||
|
};
|
||
|
|
||
|
// GraphQLDate casts the date string to new Date, we want to keep it as a string so we cast it back to a string
|
||
|
// see https://github.com/excitement-engineer/graphql-iso-date/issues/106
|
||
|
GraphQLDate.parseValue = parseAndCast(GraphQLDate.parseValue);
|
||
|
GraphQLDate.parseLiteral = parseAndCast(GraphQLDate.parseLiteral);
|
||
|
|
||
|
module.exports = GraphQLDate;
|