Gatsby Source API Server运行良好。在我的gatsby-config中使用它:
{
resolve: 'gatsby-source-apiserver',
options: {
typePrefix: 'community_education__',
url: `https://spreadsheets.google.com/feeds/list/1DLAVN3q758sPohCFeZlVSVRZKXzEser1SIsQnH2mvrw/ogwtdyp/public/basic?hl=en_US&alt=json`,
method: 'get',
name: `classes`,
entityLevel: `feed.entry`,
schemaType: classType,
localSave: true,
path: `${__dirname}/api/`,
verboseOutput: true,
}
}
它正确地提取了我想要的数据。问题是我正在使用的API(google)带回了以下属性:
{
"title": {
"type": "text",
"$t": "Computer Coding for Kids"
},
"content": {
"type": "text",
"$t": "district: Hopkins, days: Mon - Thurs, startdate: 6/11/2018, enddate: 6/14/2018, time: 9am - Noon, grades: 3rd, 4th, 5th, 6th Grades, description: Learn how to code through playing games and having fun! We'll learn the fundamentals of loops, if statements, and variables as we learn the blockly and python computer languages! Please come with internet navigation skills (basic typing and mouse control) and a passion to work hard and have fun!, link: https://hopkins.ce.eleyo.com/course/6064/youth-summer-2018/computer-coding-for-kids"
}
}
当我进行GraphQL查询时,可用的属性为type
和alternative__t
,实际上是可以的,除了alternative__t
总是返回null
。 / p>
此查询:
{
allCommunityEducationClasses {
totalCount
edges {
node {
title {
type
alternative__t
}
content {
type
alternative__t
}
}
}
}
}
返回此结果:
{
"node": {
"title": {
"type": "text",
"alternative__t": null
},
"content": {
"type": "text",
"alternative__t": null
}
}
},
{
"node": {
"title": {
"type": "text",
"alternative__t": null
},
"content": {
"type": "text",
"alternative__t": null
}
}
},
我知道问题出在$t
,如果这是我自己的API,并且可以更改响应名称属性,我会这样做,但这就是google API。我可以以某种方式重命名该财产吗?是否可以使用转义字符查询$t
?
答案 0 :(得分:0)
似乎库正在检查特殊字符,而不是$
。通过在.replace
中将.replace(/-|__|:|\$|\.|\s/g, '_');
更改为normalize.js
,我可以在代码中修复它,从而解决了我的问题。
我也提出了请求请求。 https://github.com/thinhle-agilityio/gatsby-source-apiserver/pull/1