【问题标题】:Problem with GraphQL and Next JS in Production build生产构建中 GraphQL 和 Next JS 的问题
【发布时间】:2020-04-01 18:08:12
【问题描述】:

我有一个使用NextJS 和GraphQL 的项目。直到昨天一切正常。

对于GraphQL,我正在使用Apollo GraphQL

昨天我在 GraphQL 查询中添加了新字段 pageDescription,我需要从 review 获取该字段。这是GraphQL schema的一部分

"Field Group"
type Review_Review {
    fieldGroupName: String
    "Page description that will be displayed in Google search"
    pageDescription: String
    reviewProducts: [Review_Review_reviewProducts]
}

这是我的查询

export const single_review_query = gql`
  query Review($slug: String) {
    reviewBy(slug: $slug) {
      content
      title
      featuredImage {
        sourceUrl
      }
      author {
        name
        description
        avatar(size: 32) {
          url
        }
        avatar_big: avatar(size: 60) {
          url
        }
      }
      review {
        pageDescription
        reviewProducts {
          products {
            pros
            title
            price
            notice
            platform
            link
            grade
            description
            cons
            image {
              image {
                sourceUrl
              }
            }
          }
        }
      }
    }
  }
`

这个查询在开发模式下就像一个魅力。问题是当我在构建中运行它时。它只是行不通。控制台中没有任何内容。这是来自Networks 选项卡的错误

message: "Cannot query field "pageDescription" on type "Review_Review"."
category: "graphql"

当我从查询中删除 pageDescription 时一切正常

再次。 DEV 模式下不会发生这种情况

如果您需要更多信息,请写在 cmets 中。

谢谢。

编辑哦,是的。我忘了提。这是使用 Wordpress 的无头 CMS

【问题讨论】:

    标签: build graphql next.js


    【解决方案1】:

    这是我这边的一个错误。我将 GraphQL 配置为在开发模式下从本地主机获取数据,在生产模式下从服务器获取数据,并且我没有在服务器上更新 GraphQL 模式。仅在本地主机上

    【讨论】:

      猜你喜欢
      • 2021-08-16
      • 2020-05-29
      • 1970-01-01
      • 2021-04-16
      • 2020-03-30
      • 2020-04-15
      • 2020-05-03
      • 2021-03-04
      • 2020-04-11
      相关资源
      最近更新 更多