我正在开发一个遗留代码库,在我们的 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
仅在前端代码中翻译/重命名类型。这可能吗?