首页 > 解决方案 > 类型 graphql - 将 createUnionType 设置为 InputType

问题描述

我正在使用type-graphql框架,并且我配置了一个联合类型,如下所示:

export const ActionUnion = createUnionType({
  name: 'ActionUnion',
  types: () => [CreateAction, UpdateAction, DeleteAction],
});

我想用它作为我的变异输入。但是当我运行该服务时,我收到一条错误消息:

Cannot determine GraphQL input type for userActions

有没有办法将 unionType 也配置为 InputType ?

提前致谢。

标签: typegraphql

解决方案


不,在 GraphQL 规范中,联合仅适用于对象类型。你不能有联合输入。


推荐阅读