我正在学习graphql,在这里我向API发出请求,该API以以下格式返回数据: 我想读:a,c,h和j,但我卡在入口点
{
"records":[
{
"a":"1",
"b":"2",
"c":['d','e'],
"f":
[{'g':5,'h':7},
{'i':8,'j':[1,2,3,4]}]},
{},
{}
]
}
const recordType = new GraphQLObjectType({
name: "records",
fields: () => ({
a: { type: GraphQLString },
url: { type: GraphQLString },
c:{ type: GraphQLList },
f: {type:getFtype}
})
});
const getFtype = new GraphQLList({
name: "Ftype",
fields: () => ({
//How to handle here ?
})
});
const RootQuery = new GraphQLObjectType({
name: "RootQueryType",
fields: {
records: {
type: new GraphQLList(recordType),
resolve(parent, args) {
return axios.get('https:/abcd?type='pagewise')
.then(res =>res.data)
}
}
}
});
我感到迷茫,数据是如此嵌套,仅获取a和b也会引发错误:
Expected Iterable, but did not find one for field
有人可以帮我吗?