nestjs-query
nestjs-query copied to clipboard
How to override the FilterType to make sure a date range is provided?
📚 Documentation
I'm trying to force the user to provide a date range when querying tasks using @FilterableField({ filterRequired: true, allowedComparisons: ['between'] })
. However, when I start the app, I get this error and I can't find how to fix it:
./node_modules/@nestjs/graphql/dist/utils/reflection.utilts.js:15
throw new undefined_type_error_1.UndefinedTypeError((0, lodash_1.get)(prototype, 'constructor.name'), propertyKey, index);
^
Error: Undefined type error. Make sure you are providing an explicit type for the "date" of the "TaskCalendarFilter" class.
Here's my code:
@ObjectType('TaskCalendarFilter')
@QueryOptions({ pagingStrategy: PagingStrategies.NONE })
class TaskCalendarFilter extends TaskCalendar {
@FilterableField({ filterRequired: true, allowedComparisons: ['between'] })
date: CommonFieldComparisonBetweenType<number>
}
@ArgsType()
export class TaskCalendarQuery extends QueryArgsType(TaskCalendarFilter) {}
Have you read the Contributing Guidelines on issues?
Yes
This is because between
is/was not working when defining them yourself in allowedComparisons
, this is fixed in my fork with this pr