WebDevStudios / nextjs-wordpress-starter

A headless starter for WordPress powered by Next.js.
https://webdevstudios.github.io/nextjs-wordpress-starter/
GNU General Public License v2.0
733 stars 129 forks source link

Build error occurred - Error: Cannot query field "teams" on type "RootQuery". #741

Closed eric-cortes closed 2 years ago

eric-cortes commented 2 years ago

Thanks for taking the time to file a bug report! Please fill out this form as completely as possible.

If you leave out sections there is a high likelihood it will be moved to our GitHub Discussions.

Describe the bug Error after npm run build

^CMy-User:nextjs-wordpress-starter myuser$ npm run build

@webdevstudios/nextjs-wordpress-starter@1.0.0 build /Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter next build

info - Loaded env from /Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter/.env info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5 (node:11707) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification. (Use node --trace-warnings ... to show where the warning was created) info - Checking validity of types
info - Using external babel configuration from /Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter/.babelrc info - Creating an optimized production build
info - Compiled successfully

Build error occurred Error: Cannot query field "teams" on type "RootQuery". Did you mean "terms", "tags", "menus", "tag", or "theme"? at new ApolloError (/Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter/node_modules/@apollo/client/errors/errors.cjs.js:34:28) at /Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter/node_modules/@apollo/client/core/core.cjs.js:1575:47 at both (/Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter/node_modules/@apollo/client/utilities/utilities.cjs.js:981:53) at /Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter/node_modules/@apollo/client/utilities/utilities.cjs.js:974:72 at new Promise () at Object.then (/Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter/node_modules/@apollo/client/utilities/utilities.cjs.js:974:24) at Object.next (/Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter/node_modules/@apollo/client/utilities/utilities.cjs.js:982:49) at notifySubscription (/Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter/node_modules/zen-observable/lib/Observable.js:135:18) at onNotify (/Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter/node_modules/zen-observable/lib/Observable.js:179:3) at SubscriptionObserver.next (/Users/myuser/Local Sites/example-page/app/public/wp-content/themes/nextjs-wordpress-starter/node_modules/zen-observable/lib/Observable.js:235:7) { type: 'ApolloError', graphQLErrors: [ { message: 'Cannot query field "teams" on type "RootQuery". Did you mean "terms", "tags", "menus", "tag", or "theme"?', extensions: [Object], locations: [Array] } ], clientErrors: [], networkError: null } info - Collecting page data .npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @webdevstudios/nextjs-wordpress-starter@1.0.0 build: next build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @webdevstudios/nextjs-wordpress-starter@1.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /Users/myuser/.npm/_logs/*-debug.log

Steps to reproduce the behavior: npm run build in nextjs-wordpress-starter theme folder

  1. Go to Terminal 'nextjs-wordpress-starter folder'
  2. Type 'npm run build'
  3. See error

Expected behavior Next standard build in .next folder

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

sloyer commented 2 years ago

Following up on this, just started happening to us randomly.

sloyer commented 2 years ago

This is happening up deploy to vercel

eric-cortes commented 2 years ago

Try adding a random team in WP. Like test or something like that and then rebuild and deploy. Let me know if that helps We did that...

ravewebdev commented 2 years ago

@sloyer @bosconfoona this is likely due to us removing built-in CPTs from our backend headless repos. If your WP install does not register the team CPT, this may happen on your frontend. We're working on cleaning up this repo (e.g., removing CPT handling from the frontend), but in the meantime, you should be able to fix the issue by removing your local nextjs-wordpress-starter/pages/team directory.