Merge pull request #11554 from strapi/v4/graphql-fix-date-filtering

[V4] Fix datetime filtering on GraphQL
This commit is contained in:
Alexandre BODIN 2021-11-12 17:53:23 +01:00 committed by GitHub
commit 2ce6ef7d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
'use strict';
const { has, propEq, isNil } = require('lodash/fp');
const { has, propEq, isNil, isDate, isObject } = require('lodash/fp');
// todo[v4]: Find a way to get that dynamically
const virtualScalarAttributes = ['id'];
@ -15,7 +15,9 @@ module.exports = ({ strapi }) => {
return data.map(recursivelyReplaceScalarOperators);
}
if (typeof data !== 'object') {
// Note: We need to make an exception for date since GraphQL
// automatically cast date strings to date instances in args
if (isDate(data) || !isObject(data)) {
return data;
}