问题描述
我正在创建一个新的Gutenberg ACF模块。我希望能够动态提供GraphQL中的Post对象列表,以供Gatsby读取。
这是我的代码,可在wordpress GraphiQL和Gatsby的GraphQL中使用,以返回单个帖子。
Gutenberg阻止代码:
但是,如果我将其更改为返回帖子列表,则它在wordpress GraphiQL中确实有效,但在盖茨比的GraphQL中返回空列表。
Gutenberg阻止代码:
wordpress GraphiQL:
Gatsby GraphQL:
我正在为盖茨比使用gatsby-source-wordpress-experimental 1.3.8。
我包装Post对象列表错误吗?以前有没有其他人在WP GraphQL中提供过帐类型列表?
解决方法
这是解决此问题的方法:
- 查看此内容:Custom field not saved
- 观看此视频:https://youtu.be/Po9gyc51HlQ?t=3488
- 在PHP中包含此代码:可以确保将fromType设置为原始对象,将toType设置为需要连接到list_of的对象
祝您编程愉快!