【问题标题】:gatsby-source-wordpress error: "An empty string was returned instead of a response when making a GraphQL request."gatsby-source-wordpress 错误:“发出 GraphQL 请求时返回空字符串而不是响应。”
【发布时间】:2022-02-27 04:25:04
【问题描述】:

按照gatsby wordpress tutorial 的步骤,我将必要的插件添加到我的wordpress 并创建了 gatsby 代码。一切都正确获取,除了帖子,我收到以下错误:

发出 GraphQL 请求时返回空字符串而不是响应。 这可能表明您正在运行导致 WPGraphQL 的 WordPress 过滤器 返回一个空字符串而不是响应。 请打开一个复制问题 https://github.com/gatsbyjs/gatsby/issues/new 寻求更多帮助

更新单个“post”节点时出错。

错误

TypeError:无法读取未定义的属性“帖子” 在 fetchAndCreateSingleNode (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js: 76:24) 在 processTicksAndRejections (internal/process/task_queues.js:95:5) 在 wpActionUPDATE (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js: 311:20) 在handleWpActions (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/index.js: 60:7) 在 fetchAndRunWpActions (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/index.js: 102:7) 在 fetchAndApplyNodeUpdates (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/fetch-node-updates.js: 44:36) 在 sourceNodes (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/index.ts:60:5) 在 runSteps (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/utils/run-steps.ts:41:9) 在 runAPI (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby/src/utils/api-runner-node.js:462:16)

错误 #gatsby-source-wordpress_112003

gatsby-source-wordpress

运行 sourceNodes.sourceNodes 构建步骤时遇到严重错误。 有关更多信息,请参见上文。

相关的 gatsby-config.js:

resolve: `gatsby-source-wordpress`,
       options: {
         url:
           process.env.WPGRAPHQL_URL ||
           `https://BLOGURL.com/graphql`,
         auth: {
           htaccess: {
             username: `HTACCESS-USERNAME`,
             password: `HTACCESS-PASSWORD`,
           },
         },
         schema: {
           perPage: 5, // making it slow (suggested somewhere)
           requestConcurrency: 5, // making it slow (suggested somewhere)
           previewRequestConcurrency: 2, // making it slow (suggested somewhere)
         },
       },

我可以毫无问题地在 wordpress graphQL 中查询帖子节点,它们就在那里。

任何想法如何调试这个?

【问题讨论】:

  • 你发过帖子了吗?
  • @FerranBuireu 是的,我已经发布了帖子。

标签: javascript node.js wordpress gatsby


【解决方案1】:

我通过以下方式解决了这个问题——关闭了所有插件并且它起作用了。将它们一一切换回来,并且有某个插件(与外部链接相关的东西,因此绝对不是可疑的东西)导致了问题。插件关闭后就可以使用了。

【讨论】:

    猜你喜欢
    • 2022-01-10
    • 2019-12-10
    • 2021-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-29
    相关资源
    最近更新 更多