Ios 是否有可能将阿波罗GraphQL响应映射为单一类型?

Ios 是否有可能将阿波罗GraphQL响应映射为单一类型?,ios,graphql,apollo,Ios,Graphql,Apollo,我有几个不同的突变和查询返回一个Profile对象。我想创建一个由所有这些不同调用实现的单一Profile对象,而不是调用名称空间下嵌套类型的默认Apollo行为 伪 现在: SignInWithApple() -> SignInWithApple.Profile SignInWithGoogle() -> SignInWithGoogle.Profile SignInWithEmail() -> SignInWithEmail.Profile GetProfile() -&g

我有几个不同的突变和查询返回一个Profile对象。我想创建一个由所有这些不同调用实现的单一Profile对象,而不是调用名称空间下嵌套类型的默认Apollo行为

现在:

SignInWithApple() -> SignInWithApple.Profile
SignInWithGoogle() -> SignInWithGoogle.Profile
SignInWithEmail() -> SignInWithEmail.Profile
GetProfile() -> GetProfile.Profile
我想:

SignInWithApple() -> Profile
SignInWithGoogle() -> Profile
SignInWithEmail() -> Profile
GetProfile() -> Profile
Edit*到目前为止,我已经能够通过跳过Apollo生成的响应并将原始数据解码到我创建的概要文件对象中来完成这一点,但我仍然必须制作特殊的可解码容器,以便可以打开/删除每个查询/变异的名称空间。似乎一定有更好的方法…

您可以使用它创建一个
配置文件
类型,可以是其中的任何一种

像这样

union Profile = SignInWithApple.Profile | 
  SignInWithGoogle.Profile |
  SignInWithEmail.Profile |
  GetProfile.Profile