现有类的typeGraphQL解析器

发布于 2025-01-24 14:42:46 字数 452 浏览 4 评论 0原文

如何为我无法编辑的类typegraphql编写解析器?

通常,我会有这样的情况:

@ObjectType()
export class User {
  @Field()
  f_name!: string;

  @Field()
  l_name!: string;

  @Field()
  email!: string;
}

我可以添加一个返回该类的解析器,

  @Query(() => User)
  user():Promise<User>{
    some code which returns a User
  }

现在我使用的是一个软件包来定义类trassactionOutput,并且我想将此对象用作我的GraphQl查询的返回。在不编辑该课程的情况下,我该如何完成此操作?

How can I write a resolver in typegraphql for a class I can not edit myself?

Normally I would have the situation that I write a class e.g.

@ObjectType()
export class User {
  @Field()
  f_name!: string;

  @Field()
  l_name!: string;

  @Field()
  email!: string;
}

And then I can add a resolver which returns this class

  @Query(() => User)
  user():Promise<User>{
    some code which returns a User
  }

Now I am using a package which defines a class transactionOutput and I would like to use this object as a return for my graphql query. How can I accomplish this without editing that class?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文