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

Error when applying defaultFilter in module #505

Closed
archer747 opened this issue Sep 2, 2020 · 2 comments
Closed

Error when applying defaultFilter in module #505

archer747 opened this issue Sep 2, 2020 · 2 comments
Labels
bug Something isn't working in progress

Comments

@archer747
Copy link

I am getting the following error when using defaultFilter:

nestjs-query error TS2322: Type is not assignable to type 'Filter<unknown>'.

I have the following DTO:

import { ObjectType, Field, ID, Int, GraphQLISODateTime } from "@nestjs/graphql";
import { Relation, FilterableField, Connection } from '@nestjs-query/query-graphql';
import { PlanDTO } from '../plan/plan.dto';
import { UserDTO } from '../auth/dto/users.dto';


@ObjectType('SubscriptionPlan')
@Relation('plan', () => PlanDTO, { disableRemove: true })
@Connection('users', () => UserDTO, { disableRemove: true })
export class SubscriptionPlanDTO {
    @FilterableField(() => ID)
    id: number;

    @FilterableField(() => Int)
    planId: number;

    @Field(() => Int)
    quantity: number;

    @Field(() => Int)
    price: number;

    @Field(() => Int)
    totalPrice: number;

    @FilterableField(() => Int)
    schoolId: number;
    
    @Field(() => GraphQLISODateTime )
    createdDate: Date;

    @Field(() => GraphQLISODateTime )
    startDate: Date;

    @Field(() => GraphQLISODateTime )
    endDate: Date;

    @FilterableField()
    isActive: boolean;
}

And module:

import { Module } from '@nestjs/common';
import { NestjsQueryGraphQLModule } from '@nestjs-query/query-graphql';
import { NestjsQueryTypeOrmModule } from '@nestjs-query/query-typeorm';
import { SubscriptionPlan } from './subscriptionplan.entity';
import { SubscriptionPlanDTO } from './subscriptionplan.dto';
import { SubscriptionplanService } from './subscriptionplan.service';
import { GqlAuthGuard } from '../auth/auth-gql.guard';

const guards = [GqlAuthGuard];

@Module({
    imports: [
        NestjsQueryGraphQLModule.forFeature({
          // import the NestjsQueryTypeOrmModule to register the entity with typeorm
          // and provide a QueryService
          imports: [NestjsQueryTypeOrmModule.forFeature([SubscriptionPlan])],
          // describe the resolvers you want to expose
          resolvers: [{ 
            DTOClass: SubscriptionPlanDTO, 
            EntityClass: SubscriptionPlan, 
            create: { guards },
            update: { guards },
            delete: { guards, many: { disabled: true } }, 
            read: { defaultFilter: { completed: { is: true } } },
          }],
        }),
      ],
    providers: [SubscriptionplanService],   
})

export class SubscriptionModule { }

I followed this example https://doug-martin.github.io/nestjs-query/docs/graphql/resolvers#default-filter

What am I doing wrong please?

@doug-martin
Copy link
Owner

@archer747 thank you for the bug report! I just release v0.19.2 which should address this.

Thanks again!

@archer747
Copy link
Author

Fantastic! Thank you very much for your prompt response!!

I was on v0.18.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in progress
Projects
None yet
Development

No branches or pull requests

2 participants