繁体   English   中英

type-graphql 突变的可能反射问题?

[英]Possible reflection Issues with type-graphql mutations?

我一直在尝试在最近的 nodejs 项目中使用type-graphql 我已经能够成功实现@Query方法,但我一生都无法使以下内容起作用。 我将它与 Moleculer 服务一起使用。

@Mutation()
  // eslint-disable-next-line class-methods-use-this
  removeValue((@Arg("value") value: number): void {
    console.log(value);
  } 

我收到以下错误

/home/micro-api/node_modules/type-graphql/dist/helpers/findType.js:10
 metadataDesignType = reflectedType[parameterIndex];
                                          ^
/home/micro-api/node_modules/type-graphql/dist/helpers/findType.js:1
TypeError: Cannot read property '0' of undefined

有任何想法吗 ? 我在我的搜索中看到了一些提到反射的评论,但由于我对 node 和 typescript 相当陌生,所以我有点卡住了。

我认为您面临的问题是 Mutation(或查询)不应返回任何内容或void 请检查https://github.com/MichalLytek/type-graphql/issues/318

一个简单的补丁可能是:

@Mutation(() => Boolean)  
removeValue((@Arg("value") value: number): boolean {
    console.log(value);
    return true;
} 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM