【发布时间】:2020-07-17 14:43:13
【问题描述】:
我什至不确定如何命名它,但我在获取非空值时遇到了问题......我希望有人能帮助我并告诉我我做错了什么。 ..
我从中提取的 api 返回以下格式...
{
"countrytimelinedata": [
{
"info": {
"ourid": 167,
"title": "USA",
"code": "US",
"source": "https://thevirustracker.com/usa-coronavirus-information-us"
}
}
],
"timelineitems": [
{
"1/22/20": {
"new_daily_cases": 1,
"new_daily_deaths": 0,
"total_cases": 1,
"total_recoveries": 0,
"total_deaths": 0
},
"1/23/20": {
"new_daily_cases": 0,
"new_daily_deaths": 0,
"total_cases": 1,
"total_recoveries": 0,
"total_deaths": 0
}
}
]
}
我的问题是我无法使用架构中的内容在时间线项数组中提取任何内容
我的架构如下
gql`
extend type Query {
getCountryData: getCountryData
}
type getCountryData {
countrytimelinedata: [countrytimelinedata]
timelineitems: [timelineitems]
}
type countrytimelinedata {
info: Info
}
type Info {
ourid: String!
title: String!
code: String!
source: String!
}
type timelineitems {
timelineitem: [timelineitem]
}
type timelineitem {
new_daily_cases: Int!
new_daily_deaths: Int!
total_cases: Int!
total_recoveries: Int!
total_deaths: Int!
}
`;
我希望这是问这个问题的正确地方,如果我不理解一些基本的东西,我很抱歉。
我应该使用更好的东西吗?
提前谢谢你
【问题讨论】: