2

I'm working on a legacy codebase where, in our GraphQL schema, an interface was defined as 'Subscription':

  interface Subscription {
    fieldOne: String
    fieldTwo: String
  }

  type FirstSubscriptionType implements Subscription {
    anotherField: String
  }

  type SecondSubscriptionType implements Subscription {
    yetAnotherField: String
  } 

This has worked fine (we don't use subscriptions and don't have plans to), but when I try to use graphql-codegen to auto-generate Typescript types for us to use in our frontend code, the generates step fails with this error:

Subscription root type must be Object type if provided, it cannot be Subscription

The obvious answer is to rename the interface. Sure enough, renaming to something like ISubscription fixes everything. I'm wondering if there's a way to avoid having to change anything in our schema and have graphql-codegen translate/rename the type in just the frontend code. Is this possible?

kqcef
  • 527
  • 1
  • 4
  • 17

0 Answers0