imranhsayed / nextjs-headless-wordpress

🔥 Nextjs Headless WordPress
https://codeytek.com/course/next-js-headless-wordpress-course/
GNU General Public License v3.0
640 stars 161 forks source link

ApolloClient 500 error #47

Closed bnbabu55 closed 3 years ago

bnbabu55 commented 3 years ago

I am following your tutorial and trying to build a site with NextJS and Wordpress as backend. I have my Wordpress site setup else where, so I am using only your frontend folder, copied contents of this folder to my local project directory and changed settings to meet my needs.

When I try yarn dev, I get 500 status code from ApolloClient, following is what I see in VS Code terminal.

https://circlej.smr-sandbox.com/graphql ApolloError: Response not successful: Received status code 500 at new ApolloError (C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\errors\errors.cjs.js:31:28) at C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\core\core.cjs.js:1457:19 at C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\utilities\utilities.cjs.js:936:69 at new Promise () at Object.error (C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\utilities\utilities.cjs.js:936:21) at notifySubscription (C:\Babu\Learning\NextJs\CircleJ2\node_modules\zen-observable\lib\Observable.js:140:18) at onNotify (C:\Babu\Learning\NextJs\CircleJ2\node_modules\zen-observable\lib\Observable.js:179:3) at SubscriptionObserver.error (C:\Babu\Learning\NextJs\CircleJ2\node_modules\zen-observable\lib\Observable.js:240:7) at C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\utilities\utilities.cjs.js:924:68 at Array.forEach () { graphQLErrors: [], networkError: Error [ServerError]: Response not successful: Received status code 500 at Object.throwServerError (C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\link\utils\utils.cjs.js:45:17) at C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\link\http\http.cjs.js:31:19 at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:93:5) { response: Response { size: 0, timeout: 0,

  [Symbol(Response internals)]: [Object]
},
statusCode: 500,
result: {
  code: 'internal_server_error',
  message: '<p>There has been a critical error on this website.</p><p><a href="https://wordpress.org/support/article/debugging-in-wordpress/">Learn more about debugging in WordPress.</a></p>',
  data: [Object],
  additional_errors: []
}

}, extraInfo: undefined } event - build page: /[...slug] wait - compiling... event - compiled successfully https://circlej.smr-sandbox.com/graphql https://circlej.smr-sandbox.com/graphql Error: Response not successful: Received status code 500 at new ApolloError (C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\errors\errors.cjs.js:31:28) at C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\core\core.cjs.js:1457:19 at C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\utilities\utilities.cjs.js:936:69 at new Promise () at Object.error (C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\utilities\utilities.cjs.js:936:21) at notifySubscription (C:\Babu\Learning\NextJs\CircleJ2\node_modules\zen-observable\lib\Observable.js:140:18) at onNotify (C:\Babu\Learning\NextJs\CircleJ2\node_modules\zen-observable\lib\Observable.js:179:3) at SubscriptionObserver.error (C:\Babu\Learning\NextJs\CircleJ2\node_modules\zen-observable\lib\Observable.js:240:7) at C:\Babu\Learning\NextJs\CircleJ2\node_modules\@apollo\client\utilities\utilities.cjs.js:924:68 at Array.forEach () { type: 'ApolloError', graphQLErrors: [], networkError: { name: 'ServerError', response: { size: 0, timeout: 0 }, statusCode: 500, result: { code: 'internal_server_error', message: '

There has been a critical error on this website.

Learn more about debugging in WordPress.

', data: [Object], additional_errors: [] } } }

Then on a hunch I went ahead and typed https://circlej.smr-sandbox.com/graphql endpoint in the browser get an error, looks like wp-graphql-gutenberg-0.3.7 is having problems, have you seen this error?

Fatal error: Uncaught WPGraphQLGutenberg\Blocks\RegistryNotSourcedException: Client side block registry is missing. You need to open up gutenberg or load it from WPGraphQLGutenberg Admin page. in /home/customer/www/circlej.smr-sandbox.com/public_html/wp-content/plugins/wp-graphql-gutenberg-0.3.7/src/Blocks/Registry.php:41 Stack trace: #0 /home/customer/www/circlej.smr-sandbox.com/public_html/wp-content/plugins/wp-graphql-gutenberg-0.3.7/src/Schema/Types/BlockTypes.php(253): WPGraphQLGutenberg\Blocks\Registry::get_registry() #1 /home/customer/www/circlej.smr-sandbox.com/public_html/wp-includes/class-wp-hook.php(287): WPGraphQLGutenberg\Schema\Types\BlockTypes->WPGraphQLGutenberg\Schema\Types{closure}(Object(WPGraphQL\Registry\TypeRegistry)) #2 /home/customer/www/circlej.smr-sandbox.com/public_html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array) #3 /home/customer/www/circlej.smr-sandbox.com/public_html/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #4 /home/customer/www/circlej.smr-sandbox.c in /home/customer/www/circlej.smr-sandbox.com/public_html/wp-content/plugins/wp-graphql-gutenberg-0.3.7/src/Blocks/Registry.php on line 41

Thanks for any help.

imranhsayed commented 3 years ago

Please click on Update Block Registry in Wp dashboard GraphQL Gutenberg and if still does not work, ensure you have latest version of WordPress plugins

bnbabu55 commented 3 years ago

I clicked on update Block registry as you suggested and it worked like magic. Thanks a lot for the timely help. Will continue to explore your tutorial.