Mileta Dulovic
Mileta Dulovic

Reputation: 1064

Problem with GraphQL and Next JS in Production build

I have a projectwhere I use NextJS and GraphQL. Everything was working fine until yesterday.

For GraphQL I am using Apollo GraphQL

Yesterday I added new field pageDescription to GraphQL query that I need to get from review. Here is part from GraphQL schema

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

And here is my query

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
              }
            }
          }
        }
      }
    }
  }
`

This query works like a charm in dev mode. The problem is when I run it in build. It just doesn't work. There is nothing in the console. Here is the error from Networks tab

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

Everything works fine when I remove pageDescription from query

Again. This doesn't happen in DEV mode

If you need more info write in comments.

Thank you.

EDIT Oh yeah. I forgot to mention. This is headless CMS that is using Wordpress

Upvotes: 1

Views: 923

Answers (1)

Mileta Dulovic
Mileta Dulovic

Reputation: 1064

It was a mistake on my side. I configured GraphQL to fetch data from localhost when in development mode and from the server in production mode and I didn't update GraphQL schema on the server. Only on localhost

Upvotes: 1

Related Questions