Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to override the FilterType to make sure a date range is provided? #1523

Open
GP4cK opened this issue Mar 3, 2022 · 1 comment
Open
Labels
documentation Improvements or additions to documentation

Comments

@GP4cK
Copy link

GP4cK commented Mar 3, 2022

📚 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

@GP4cK GP4cK added the documentation Improvements or additions to documentation label Mar 3, 2022
@TriPSs
Copy link

TriPSs commented Jun 6, 2022

This is because between is/was not working when defining them yourself in allowedComparisons, this is fixed in my fork with this pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants