如何为 GraphQL 中的字符串数组的对象属性创建模式?我希望响应看起来像这样:
{
name: "colors",
keys: ["red", "blue"]
}
这是我的架构
var keysType = new graphql.GraphQLObjectType({
name: 'keys',
fields: function() {
key: { type: graphql.GraphQLString }
}
});
var ColorType = new graphql.GraphQLObjectType({
name: 'colors',
fields: function() {
return {
name: { type: graphql.GraphQLString },
keys: { type: new graphql.GraphQLList(keysType)
};
}
});
当我运行这个查询时,我得到一个错误并且没有数据,错误只是[{}]
查询 { 颜色 { 名称,键 } }
但是,当我运行查询以仅返回名称时,我得到了成功的响应。
查询 { 颜色 { 名称 } }
当我查询键时,如何创建一个返回字符串数组的模式?