nestjs-query
nestjs-query copied to clipboard
Unable to create filter comparison for [null].
Describe the bug
I'm using @nestjs-query/query-typegoose
and when I run my app it said: Unable to create filter comparison for [null].
To Reproduce This is my dto:
@ObjectType('ApiKey')
@KeySet(['id'])
export class ApiKeyDto {
@FilterableField(() => ID)
id!: string;
@FilterableField()
name: string;
@FilterableField({ nullable: true })
description?: string;
@FilterableField(() => [String], { nullable: true })
scopes?: string[];
@FilterableField(() => [String], { nullable: true })
ipRestrictions?: string[];
@FilterableField(() => [String], { nullable: true })
referrerRestrictions?: string[];
@FilterableField(() => GraphQLISODateTime)
createdAt: Date;
@FilterableField(() => GraphQLISODateTime)
updatedAt: Date;
}
Expected behavior It's working when I use it
@FilterableField(() => [String], { nullable: true })
scopes?: string[];
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- Node Version 12.18.3
- Nestjs-query Version 0.24.4
@doug-martin - Can you say if arrays can be filterable in general? There doesn't seem to be an example in the e2e tests and before I go digging deeper, maybe you know off-hand. I ask because if it isn't possible to have arrays filterable, then I'd say this is "as designed" and thus should be a feature request?
Scott
I have to declare explicitly like this for it to work:
@FilterableField(() => [String], {
allowedComparisons: ['eq', 'neq', 'in', 'notIn'],
})
scopes: string[];
And if you add the nullable property again?
Scott
@viennv1709 and @smolinari Arrays are not currently supported, as they could be stored in a number of different ways (JSON, Postgres Array etc).
I started work on custom operators to allow this, but it was getting too complex to keep it type safe and extensible, so I put it down for a bit. I hope to get back to it sooner than later but I can't make any promises ATM.
And if you add the nullable property again?
Scott
yes
I can imagine how complex this could get. Thanks for the info @doug-martin.
Scott
How to support array of embed documents?
I would love to have support for filtering arrays in this great lib. Can confirm, I always get likeStr.replace is not a function
Error when I try to filter an array. Is there some kind of workaround for this?