【发布时间】:2021-01-01 00:07:46
【问题描述】:
我的解析器可以返回 PostType 列表或 ErrorType。但是,我似乎无法在 GraphQL 中描述这种场景:
const PostGetAllResponseType: GraphQLUnionType = new GraphQLUnionType({
name: 'PostGetAllResponse',
types: [GraphQLList(PostType), ErrorType],
resolveType(value) {
if (_.isArray(value)) {
return GraphQLList(PostType)
}
return ErrorType
},
})
如何定义一个类型是 GraphQLList 而另一种类型不是(列表)的 GraphQLUnion?
【问题讨论】:
标签: graphql graphql-js