小编h4s*_*sop的帖子

GraphQL + NestJS - 如何在守卫中访问@Args?

我需要以某种方式objectId@Args警卫内部访问,以便检查发件人是否已objectId分配给他的帐户。知道我如何实现它吗?

 @Query(() => [Person])
      @UseGuards(ObjectMatch)
      async pplWithObject(@Args('objectId') id: string): Promise<Person[]> {
        return await this.objService.getPeopleWithObject(id);
      }
Run Code Online (Sandbox Code Playgroud)

是否可以从上下文访问传递的参数?

const ctx = GqlExecutionContext.create(context);
    const request = ctx.getContext().req;
Run Code Online (Sandbox Code Playgroud)

args guard graphql nestjs

6
推荐指数
1
解决办法
1891
查看次数

NestJS-Mongoose:无法在 ChangeEvent&lt;any&gt; 上访问 fullDocument

我有以下基本代码片段,我的目标是从 获取 fullDocument 属性,obj: ChangeEvent但是我无法访问此属性 ( Property 'fullDocument' does not exist on type 'ChangeEvent<any>')。我可以访问的唯一属性是 _id、clusterTime 和 operationType。有什么我遗漏的,还是我应该非直接查询 fullDocument ( obj['fullDocument'])?

const changeStream = this.model.watch([], { fullDocument: 'updateLookup' })
      .on('change', obj => {
        console.log(obj.fullDocument);
      });
Run Code Online (Sandbox Code Playgroud)

model watch mongoose typescript nestjs

5
推荐指数
1
解决办法
112
查看次数

标签 统计

nestjs ×2

args ×1

graphql ×1

guard ×1

model ×1

mongoose ×1

typescript ×1

watch ×1