Graphql NestJS:使用ResolveProperty时出现问题。得到;未处理的PromisejectionWarning:TypeError:";

Graphql NestJS:使用ResolveProperty时出现问题。得到;未处理的PromisejectionWarning:TypeError:";,graphql,code-first,nestjs,Graphql,Code First,Nestjs,我有一个父模型(摄像头),其中包含子(输送机)的id,如下所示: @ObjectType('camera') export class CameraModel { @Field(() => ID) _id: String; @Field() name: String; @Field(() => ConveyorModel) conveyor: ConveyorModel; } 因此,为了获得“传送带”的详细信息,我需要在camera.resolver.

我有一个父模型(摄像头),其中包含子(输送机)的id,如下所示:

@ObjectType('camera')

export class CameraModel {
  @Field(() => ID)
  _id: String;

  @Field()
  name: String;

  @Field(() => ConveyorModel)
  conveyor: ConveyorModel;
}
因此,为了获得“传送带”的详细信息,我需要在camera.resolver.ts中使用@ResolveProperty decorator(注意:仅显示相关方法)

运行服务器后,我发现以下错误。主要来自graphql模式生成器

(node:30636) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getObjectType' of undefined

...

(node:30636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:30636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
但是,如果我注释掉@ResolveProperty块,一切都很顺利。但我不能只得到传送带的细节(只得到ID)


我错过了什么

基于我在

已经修好了

不要使用@Resolver('YourModel')的字符串基修饰符。只需使用@Resolver(of=>YourModel)


这部分NestJS的文档确实不够

基于我在

已经修好了

不要使用@Resolver('YourModel')的字符串基修饰符。只需使用@Resolver(of=>YourModel)


这部分NestJS的文档确实不够

从文档中看,
@Resolver(of=>type)
用于
代码优先
方法,
@Resolver('string')
用于
模式优先
方法。从文档中看,
@Resolver(of=>type)
用于
代码优先
方法和
@Resolver('string'))
适用于
模式优先
方法。
(node:30636) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getObjectType' of undefined

...

(node:30636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:30636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.