TriPSs / nestjs-query

Easy CRUD for GraphQL.
https://tripss.github.io/nestjs-query/
MIT License
152 stars 43 forks source link

Nest can't resolve dependencies of the MarkdownActivityAuthorizerInterceptor #231

Closed blueMountain007 closed 6 months ago

blueMountain007 commented 6 months ago

Describe the bug A clear and concise description of what the bug is.

Have you read the Contributing Guidelines?

Yes

To Reproduce Steps to reproduce the behavior:

  1. clone the small reproducible demo repository: https://github.com/xin-ze/nestjs_reproduction/tree/main
  2. select 'main' branch
  3. refer to README.md and execute the code, will encounter an error: nestjs cannot find the generated AuthorizerProviders

Expected behavior This error disappears

Screenshots

image

code path: apps/content/src/app/markdown/markdown.module.ts

image

Desktop (please complete the following information):

TriPSs commented 6 months ago

Please follow the docs.

You need to change the module to look more like this:

@Module({
  exports: [],
  imports: [
    NestjsQueryGraphQLModule.forFeature({
      imports: [TypeOrmModule.forFeature([MarkdownActivity])],
      services: [MarkdownActivityService],
      resolvers: [
        {
          DTOClass: YourDTO,
          EntityClass: MarkdownActivity,
        },
      ],
    }),
  ],
  providers: [
    MarkdownActivityResolver,
  ],
})
export class MarkdownModule {}
blueMountain007 commented 6 months ago

@TriPSs Thank you! I have one more question: do I have to declare a DTO class? There is no such concept in the demo code. After rewriting it like this, the error is still reported.

image image

The demo code has been updated and you should be able to reproduce it locally.