【发布时间】:2021-04-10 09:59:34
【问题描述】:
在将响应发送回 Nestjs/graphql 之前拦截响应的最佳方法是什么?
我正在尝试拦截查询结果的响应,在将其发回之前将一些数据提取到 context.extensions 中。 我尝试使用 graphql-middleware 应用中间件,但它不起作用。
这是我尝试过的
export const Pagination: MiddlewareFn = async ({ info }, next) => {
// here i'm trying to extract the data
};
这就是我要放置的地方(resolver.ts)
@UseMiddleware(Pagination)
findAll(options: PaginationInput): Promise<PaginatedReport> {
return applyPagination(this.reportRepository, options);
}
【问题讨论】:
标签: typescript graphql nestjs middleware