All we need is an easy explanation of the problem, so here it is.
Following the steps at the gatsby wordpress tutorial, I added the necessary plugins to my wordpress and created the gatsby code. Everything is properly fetched, except for posts, I receive the following error:
An empty string was returned instead of a response when making a GraphQL request.
This may indicate that you have a WordPress filter running which is causing WPGraphQL
to return an empty string instead of a response.
Please open an issue with a reproduction at
https://github.com/gatsbyjs/gatsby/issues/new
for more helpError occurred while updating a single "post" node.
ERROR
TypeError: Cannot read property ‘post’ of undefined
at fetchAndCreateSingleNode (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js:76:24)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at wpActionUPDATE (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js:311:20)
at handleWpActions (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/index.js:60:7)
at fetchAndRunWpActions (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/index.js:102:7)
at fetchAndApplyNodeUpdates (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/fetch-node-updates.js:44:36)
at sourceNodes (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/steps/source-nodes/index.ts:60:5)
at runSteps (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby-source-wordpress/src/utils/run-steps.ts:41:9)
at runAPI (/Users/bbt/Documents/Work/my-wordpress-gatsby-site-2/node_modules/gatsby/src/utils/api-runner-node.js:462:16)ERROR #gatsby-source-wordpress_112003
gatsby-source-wordpress
Encountered a critical error when running the sourceNodes.sourceNodes build step.
See above for more information.
Relevant gatsby-config.js:
resolve: `gatsby-source-wordpress`,
options: {
url:
process.env.WPGRAPHQL_URL ||
`https://BLOGURL.com/graphql`,
auth: {
htaccess: {
username: `HTACCESS-USERNAME`,
password: `HTACCESS-PASSWORD`,
},
},
schema: {
perPage: 5, // making it slow (suggested somewhere)
requestConcurrency: 5, // making it slow (suggested somewhere)
previewRequestConcurrency: 2, // making it slow (suggested somewhere)
},
},
I can query the post nodes in the wordpress graphQL without a problem, they are there.
Any ideas how to debug this?
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
Method 1
I solved it the following way — switched off all plugins and it worked. Switched them back one-by-one, and there was a certain plugin (something related to external links, so absolutely not something that was suspicious) that caused the problem. It works since the plugin is switched off.
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0