带有打字稿的 Graphql 别名

时间:2021-01-27 14:56:32

标签: typescript graphql

在 graphql 中使用别名时,告诉 typescript 别名存在的正确方法是什么?

  query GetAssets {
    red: assets(type: "red") {
      uuid
      name
    }
    blue: assets(type: "blue") {
      uuid
      name
    }
  }

但是生成的类型文件只包括:

export type Query = {
  assets?: Maybe<AssetData>
}

我想访问 data.red,但只有 data.assets 是已知类型。

0 个答案:

没有答案