【问题标题】:After adding more products to woocomerce wordpress store graphql fails向 woocommerce wordpress 商店添加更多产品后,graphql 失败
【发布时间】:2021-11-01 18:42:44
【问题描述】:

有人知道如何解决这个 graphql 错误吗?它出现在我添加了更多 woocomerce 产品之后。网址似乎很好,因为在删除了部分 woocomerce 产品后,所有星星都可以再次正常工作。

ERROR 

timeout of 30000ms exceeded


 ERROR #gatsby-source-wordpress_111006 

 gatsby-source-wordpress  It took too long for https://my-web-url/graphql to respond (longer than 30 seconds).

Either your URL is wrong, you need to increase server resources, or you need to decrease the amount of resources each
request takes.

You can configure how much resources each request takes by lowering your `options.schema.perPage` value from the default
of 100 nodes per request.
Alternatively you can increase the request timeout by setting a value in milliseconds to `options.schema.timeout`, the
current setting is 30000.

GraphQL request to https://my-web-url/graphql failed.

【问题讨论】:

  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: reactjs wordpress graphql gatsby


【解决方案1】:

输出是不言自明的。由于要获取更多数据,您已达到超时阈值。

根据提示,您可以在gatsby-sourde-wordpress 中添加一堆options 来自定义该限制:

{
  resolve: `gatsby-source-wordpress`,
  options: {
    schema: {
      timeout: 30000,
    },
  },
}

timeout,默认取值为 30000ms。

此外,您可以更改按页面获取的节点数(perPage)。

混合两种自定义:

{
  resolve: `gatsby-source-wordpress`,
  options: {
    schema: {
      timeout: 30000,
      perPage: 100,
    },
  },
}

尝试增加这些默认值以查看您的请求是否成功。

【讨论】:

    【解决方案2】:

    要解决此问题,您需要通过添加选项架构来提高 gatsby-config.js 文件中的超时时间。 options: {schema: { timeout: 1000000,},}

    但是仅仅这样做可能还不够,因为如果您遇到超时错误,您的 wordpress 服务器要么已经超载,要么很快就会超载。您需要在 wordpress 服务器中提高分配的内存。您可以通过使用一些 FTP 软件(如 filezilla)并将这一行添加到 wp.config 文件中来做到这一点。 define( ‘WP_MEMORY_LIMIT’, ‘512M’ ); 如果您没有那么多数据,您应该选择较小的数字,例如 256MB。

    【讨论】:

      猜你喜欢
      • 2021-11-15
      • 2019-08-26
      • 1970-01-01
      • 2017-06-24
      • 2021-11-03
      • 2015-11-11
      • 2020-11-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多