问题描述
我正在处理一个遗留代码库,在我们的 GraphQL 架构中,一个接口被定义为“订阅”:
interface Subscription {
fieldOne: String
fieldTwo: String
}
type FirstSubscriptionType implements Subscription {
anotherField: String
}
type SecondSubscriptionType implements Subscription {
yetAnotherField: String
}
这很有效(我们不使用订阅,也没有计划),但是当我尝试使用 graphql-codegen
自动生成 Typescript 类型以供我们在前端代码中使用时, generates
步骤因以下错误而失败:
Subscription root type must be Object type if provided,it cannot be Subscription
显而易见的答案是重命名接口。果然,重命名为 ISubscription
之类的东西可以解决所有问题。我想知道是否有一种方法可以避免更改我们架构中的任何内容,并让 graphql-codegen
仅在前端代码中翻译/重命名类型。这可能吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)