Express 无法读取属性';上下文';未定义图形的定义

Express 无法读取属性';上下文';未定义图形的定义,express,graphql,typegraphql,Express,Graphql,Typegraphql,我正在使用Typescript、Express、TypeORM、GraphQL和TypeGraphQL构建一个允许用户登录的小应用程序 但是,当我在GraphQL游乐场上点击我的测试查询bye时,我得到: Cannot read property 'context' of undefined "TypeError: Cannot read property 'context' of undefined", " at new exports.isAuth // isA

我正在使用Typescript、Express、TypeORM、GraphQL和TypeGraphQL构建一个允许用户登录的小应用程序

但是,当我在GraphQL游乐场上点击我的测试查询
bye
时,我得到:

Cannot read property 'context' of undefined
"TypeError: Cannot read property 'context' of undefined",
            "    at new exports.isAuth // isAuth is a JS file I wrote
MyContext.js

import { Request, Response } from "express";

export interface MyContext {
  req: Request;
  res: Response;
  payload?: { userId: string };
}
import { MiddlewareFn } from "type-graphql";
import { verify } from "jsonwebtoken";
import { MyContext } from "./MyContext";

export const isAuth: MiddlewareFn<MyContext> = ({ context }, next) => {
  const authorization = context.req.headers["authorization"];

  if (!authorization) {
    throw new Error("not authorized");
  }
...
isAuth.js

import { Request, Response } from "express";

export interface MyContext {
  req: Request;
  res: Response;
  payload?: { userId: string };
}
import { MiddlewareFn } from "type-graphql";
import { verify } from "jsonwebtoken";
import { MyContext } from "./MyContext";

export const isAuth: MiddlewareFn<MyContext> = ({ context }, next) => {
  const authorization = context.req.headers["authorization"];

  if (!authorization) {
    throw new Error("not authorized");
  }
...
我不确定为什么文件
isAuth.js

中的
上下文未定义,原因是:

1) 进入
/tsconfig.json


2) 将
“目标”:“es5”
更改为
“目标”:“es6”

阿米丽特的本·阿瓦德?