I'm was using type-graphql to create a simple API. So I created a simple query which is working fine before.
@Resolver()
class B {
@Query({nullable: true})
async a(@Arg("b", () => String) b: string) {
}
}
But when I integrated babel in my project it's start throwing this error:
/Users/robot/Desktop/node-test/src/index.ts:37
var _a = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(@(0, _typeGraphql.Arg)("b", function () {
^
SyntaxError: Invalid or unexpected token
.babelrc:
{
"presets": [
"@babel/preset-env",
"@babel/preset-typescript"],
"plugins": [
["@babel/plugin-proposal-decorators", {"legacy": true}],
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-typescript",
"@babel/plugin-transform-runtime"
]
}
Try removing
{"legacy": true}
from your.babelrc
unless you are sure that you need it. If you do need it, using{"legacy": true}
with@babel/plugin-proposal-decorators
needs some additional configuration according to https://babeljs.io/docs/en/babel-plugin-proposal-decorators#legacy :The example configuration they give is
Applying that to example to your
.babelrc
would change it to the following. Does that solve your issue?