微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Apollo 客户端 GraphQL 查询:JSON 输入意外结束

如何解决Apollo 客户端 GraphQL 查询:JSON 输入意外结束

我正在使用 NextJS 和 WP WooCommerce 来构建我自己的网站。认情况下,查询结果最多只返回 100 个结果,但我将其更改为 1000 个,这不是问题。
当我用这样的查询发出请求时:

query MyQuery {
    products(first: 120) {
      nodes {
        id
        image {
          sourceUrl
        }
        name
        onSale
        productCategories {
          nodes {
            slug
          }
        }
        productTags {
          nodes {
            slug
          }
        }
        sku
        status
        totalSales
        type
        visibleProducts {
          nodes {
            slug
            isRestricted
          }
        }
        ... on VariableProduct {
          manageStock
          onSale
          price(format: RAW)
          regularPrice(format: RAW)
          salePrice(format: RAW)
          soldindividually
          weight
          width
        }
        ... on ExternalProduct {
          onSale
          price(format: RAW)
          regularPrice(format: RAW)
          salePrice(format: RAW)
        }
        ... on SimpleProduct {
          price(format: RAW)
          regularPrice(format: RAW)
          salePrice(format: RAW)
          virtual
          weight
          width
        }
      }
    }
  }   

没关系。没问题。
但是,当我想加载更多产品时,例如 140,我收到一条错误消息:

SyntaxError: Unexpected end of JSON input
at https://domain.info/sub/wp-content/plugins/wp-graphql/src/Admin/GraphiQL/app/build/static/js/main.b7d08b5b.js?ver=5.6.2:1:597992  

enter image description here

它看起来像重载 JSON 长度或类似的东西?我不明白。我怎么解决这个问题?我在这里不需要分页,因为我想为静态站点生成获取所有产品(大约 150 项)。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。