Comments (9)
Just added @Injectable({ scope: Scope.REQUEST })
on dataloader provider. Btw, I'm using another library: https://github.com/jonathborg/nestjs-graphql-dataloader
from nestjs-dataloader.
The same is true for me. One dataloader is good,but two will not work。
What about this error? I'm not asking for a fix. But, do you know what means?
I followed the steps, one by one. I tryed to put the interceptor inside local module and app.module.
The error show up only when I implement 2 dataloaders. It works nice with one dataloader.Nest version: ^7.4.2
The same is true for me. One dataloader is good,but two will not work。
from nestjs-dataloader.
{
provide: APP_INTERCEPTOR,
useClass: DataLoaderInterceptor,
}
If this is used twice, the error will be reported.This is the mistake:
Nest could not find xxx element (this provider does not exist in the current context)
from nestjs-dataloader.
Sorry for taking so long to get back. But for starters, you should only place the interceptor in one module. After doing that, if that module is not the global module, import that module to the global module. Let me know if that makes sense, and we can keep troubleshooting from there
from nestjs-dataloader.
@liangwei0101, that's by design. We don't want to instances of this class, as that would defeat the purpose of one thing loading everything at once. That's why we create a single instance in a single module, and then share that module
from nestjs-dataloader.
Sorry for taking so long to get back. But for starters, you should only place the interceptor in one module. After doing that, if that module is not the global module, import that module to the global module. Let me know if that makes sense, and we can keep troubleshooting from there
It means that all implementations of dataloader should be placed in one place? For example:
@Module({
imports: [TypeOrmModule.forFeature([XXX1, XXX2, XX3])],
providers: [
xxx1DataLoader,
xxx2DataLoader,
xxx3DataLoader,
xxx4DataLoader,
xxx5DataLoader,
xxx6DataLoader,
{
provide: APP_INTERCEPTOR,
useClass: DataLoaderInterceptor,
},
],
})
export class DataLoaderModule {}
That's what it means?
from nestjs-dataloader.
That dataloaderinterceptor should be in a single module, generally the global, or in a module for the resolvers. You can then have your specific dataloader classes wherever they need in other modules
from nestjs-dataloader.
This is how I have it setup
@Module({ imports: [ServicesModule], providers: [ AccountResolver, AuthenticationResolver, CompanyResolver, DateTimeScalar, DateScalar, JobBreakdownResolver, JobAreaResolver, MileageRecordingResolver, SupervisorReminderResolver, SupervisorNoteResolver, UserEventResolver, { provide: APP_GUARD, useClass: AuthenticationGuard, scope: Scope.REQUEST, inject: [AuthenticationService], }, { provide: APP_INTERCEPTOR, useClass: DataLoaderInterceptor, }, { provide: APP_INTERCEPTOR, useClass: EventInterceptor, }, ], }) export class ResolversModule {}
And then I have my dataloaders in their specific domain modules, and export them.
@Module({ imports: [ ConfigModule, IntegrationsModule, UserPermissionModule, TypeOrmModule.forFeature([ AccountRepository, AccountRegistrationRepository, ForgottenPasswordRepository, SeedAccountRepository, ]), ], providers: [ AccountLoader, AccountService, RegistrationService, SeedAccountService, ], exports: [ AccountLoader, AccountService, RegistrationService, SeedAccountService, ], }) export class AccountModule { }
Sorry about formatting, I'm on mobile.
from nestjs-dataloader.
This is how I have it setup
@Module({ imports: [ServicesModule], providers: [ AccountResolver, AuthenticationResolver, CompanyResolver, DateTimeScalar, DateScalar, JobBreakdownResolver, JobAreaResolver, MileageRecordingResolver, SupervisorReminderResolver, SupervisorNoteResolver, UserEventResolver, { provide: APP_GUARD, useClass: AuthenticationGuard, scope: Scope.REQUEST, inject: [AuthenticationService], }, { provide: APP_INTERCEPTOR, useClass: DataLoaderInterceptor, }, { provide: APP_INTERCEPTOR, useClass: EventInterceptor, }, ], }) export class ResolversModule {}
And then I have my dataloaders in their specific domain modules, and export them.
@Module({ imports: [ ConfigModule, IntegrationsModule, UserPermissionModule, TypeOrmModule.forFeature([ AccountRepository, AccountRegistrationRepository, ForgottenPasswordRepository, SeedAccountRepository, ]), ], providers: [ AccountLoader, AccountService, RegistrationService, SeedAccountService, ], exports: [ AccountLoader, AccountService, RegistrationService, SeedAccountService, ], }) export class AccountModule { }
Sorry about formatting, I'm on mobile.
I see. Thank you
from nestjs-dataloader.
Related Issues (20)
- Dataloader executing in HttpRequest with empty context in NestJSv7 HOT 2
- Error with Nest v7
- Property 'generateDataLoader' in type ... is not assignable to the same property in base type HOT 4
- Accessing graphql context from loader HOT 6
- Compatibility issue with nest v7.1.2 HOT 1
- ID order in example HOT 1
- Unnecessary function wrap HOT 1
- Problem with @Subscription(): stale data is returned for the lifetime of the subscription HOT 3
- Building my lambda using serverless-webpack throwing error 'Module '"../../../node_modules/nestjs-dataloader/dist"' has no exported member 'NestDataLoader'.'
- Problem with GlobalPipes(ValidationPipe)
- Quick Question Job offer HOT 1
- Property 'intercept' in type 'DataLoaderInterceptor' is not assignable to the same property in base type 'NestInterceptor<any, any>'. HOT 3
- Support Nestjs 8
- Help with maintaining
- Remove "graphql" as a peer dependency HOT 1
- ESLint: 'idText' is declared but its value is never read.
- Missing types in 9.0.0 HOT 1
- Usage in @FieldResolver() HOT 1
- Strict type checking + custom cacheKeyFn gives a compile error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs-dataloader.