Skip to content

Usage in @FieldResolver() #61

@vinaybedre

Description

@vinaybedre

Hi,

Is it possible to use nestjs-dataloader with something like below?

@Resolver(() => AccountDto)
export class AccountFieldResolver {
  constructor(private queryBus: QueryBus) {}

  @ResolveField(() => [AccountDto], { name: 'account' })
  async resolveCompanyAbsences(
    @Args('input') { id }: AccountKey,
    @Loader(CompanyEmployeeAbsenceLoader) accountLoader: DataLoader<AccountKey, Account>,
  ) {
     return accountLoader.load({ id });
  }

Seems that the interceptor is not being initialized and it fails with error
You should provide interceptor ${DataLoaderInterceptor.name} globally with ${APP_INTERCEPTOR}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions