Appollo 服务器 - 拦截解析器以获得每个的解析时间? (打字稿)

问题描述 投票:0回答:0

我有 25 个解析器,我不想在每个解析器中编写一个记录器,而是想使用某种拦截器来记录每个解析器的时间。我要传入

plugins
如下图:

plugins: [
            {
               {
      requestDidStart: async (args, next) => {
        const start = new Date().getTime();
        const result = await next();
        const end = new Date().getTime();
        console.log(`Time of execution for ${args.contextDetails.operationName}: ${end-start}`);
        return result;
      },
    }
        }
]
apollo-server
© www.soinside.com 2019 - 2024. All rights reserved.