WordPress&x2B;盖茨比定制休息路线未显示在图形QL中
我是盖茨比的新手,我正在尝试使用WP作为内容提供商来建立一个网站。我有一个自定义的休息路线内置在WPWordPress&x2B;盖茨比定制休息路线未显示在图形QL中,wordpress,graphql,gatsby,Wordpress,Graphql,Gatsby,我是盖茨比的新手,我正在尝试使用WP作为内容提供商来建立一个网站。我有一个自定义的休息路线内置在WP wp-json/lbt/v1/settings 现在它又回来了 { "time_and_location": "Testing" } 我似乎无法找到如何在我的盖茨比网站的graphQL中使用该路线。我在我的includedRoutes中将其设置为 includedRoutes: [ '/*/*/categories', '/*/*/posts', '/**/lbt/**', '/*/*
wp-json/lbt/v1/settings
现在它又回来了
{
"time_and_location": "Testing"
}
我似乎无法找到如何在我的盖茨比网站的graphQL中使用该路线。我在我的includedRoutes中将其设置为
includedRoutes: [
'/*/*/categories',
'/*/*/posts',
'/**/lbt/**',
'/*/*/events',
'/*/*/pages',
'/*/*/media',
'/*/*/tags',
'/*/*/taxonomies',
'/*/*/menus'
],
当我旋转盖茨比时,我也看到了这一点
-> wordpress__lbt_v1 fetched : 1
-> wordpress__lbt_settings fetched : 1
我已经搜索了很多不同的网站,但我没有找到任何东西。非常感谢您的帮助。您需要在“gatsby config.js”中添加自定义规范化程序 像 ... 插件:[ ....., { 决议:“盖茨比来源wordpress”, 选项:{ ...... normalizers:normalizers=>[MapCustomAPI,…normalizers], } } ...... 添加“MapCustomAPI”规范化程序,如 const mapCustomApis = { name: `mapCustomApis`, normalizer: function({ entities }) { return entities.reduce((acc, e) => { return acc.concat(e); }, []); } } 常量MapCustomAPI={ 名称:`MapCustomAPI`, 规范化器:函数({entities}){ 返回实体。减少((acc,e)=>{ 根据concat(e)返回; }, []); } }
- 我从中复制了代码 支持我的自定义API响应
- 确保你的normailzer比其他的normalizer早