GraphQL - 类型为“[User]”的字段 "x" 必须选择子字段。你是说“x{ ... }
GraphQL - Field "x" of type "[User]" must have a selection of subfields. Did you mean "x{ ... }
我正在尝试获取以下简单查询:
{duel{id, players}}
我收到以下错误:
Field "players" of type "[User]" must have a selection of subfields. Did you mean "players { ... }
我的决斗类型结构:
const DuelType = new ObjectType({
name: 'Duel',
fields: () => ({
id: { type: new NonNull(ID) },
round_id: { type: IntType },
status: { type: StringType },
turn_of_user_id: { type: IntType },
winner: { type: StringType },
players: { type: new GraphQLList(UserType) },
}),
});
知道我错过了什么吗?
谢谢。
您必须在 UserType
中指定要为 players
列表中的每个项目获取的字段。假设 UserType
有一个 name
字段,此示例适用于您的用例:
{
duel {
id,
players {
name
}
}
}
我正在尝试获取以下简单查询:
{duel{id, players}}
我收到以下错误:
Field "players" of type "[User]" must have a selection of subfields. Did you mean "players { ... }
我的决斗类型结构:
const DuelType = new ObjectType({
name: 'Duel',
fields: () => ({
id: { type: new NonNull(ID) },
round_id: { type: IntType },
status: { type: StringType },
turn_of_user_id: { type: IntType },
winner: { type: StringType },
players: { type: new GraphQLList(UserType) },
}),
});
知道我错过了什么吗?
谢谢。
您必须在 UserType
中指定要为 players
列表中的每个项目获取的字段。假设 UserType
有一个 name
字段,此示例适用于您的用例:
{
duel {
id,
players {
name
}
}
}