Я хочу создать тип graphql, который может возвращать либо Array of Integers
, либо String
.
. Я уже пытался использовать union в форме union CustomVal = [Int] | String
, но это возвращает ошибку.
Объявление схемы:
union CustomValues = [Int] | String
type Data {
name: String
slug: String
selected: Boolean
values: CustomValues
}
Ошибка:
node_modules/graphql/error/syntaxError.js:24
return new _GraphQLError.GraphQLError('Syntax Error: ' + description, undefined, source, [position]);
Syntax Error: Expected Name, found [
GraphQL request (81:23)
80:
81: union CustomValues = [Int] | String
Возможно ли это сделать в graphql?Если нет, не могли бы вы предложить альтернативу для этого.
Я спрашиваю об этом, поскольку в документации профсоюза говорится, что Note that members of a union type need to be concrete object types; you can't create a union type out of interfaces or other unions.
Любые решения будут очень полезны.