The issue here, besides your gatsby-node.js
looks good and the pages should be created correctly, is that you don't have a connection to your WordPress site and the code breaks at:
_.each(result.data.allWpPage.edges, edge => {
Because allWpPage
is undefined
.
In addition, your promise rejection is not doing what it should (because it's not throwing any exception:
if (result.errors) {
console.log(result.errors)
reject(result.errors)
}
Should be something like:
if (!result) {
console.log(result.errors)
reject(result.errors)
}
The issue is:
{
resolve: 'gatsby-source-wordpress',
options: {
"url": "http://learn.test/graphql"
}
This URL doesn't seem to be providing any valid GraphQL schema.
I'd recommend following one of the gatsby-plugin-wordpress
tutorials or diving directly on one of the starters which has a minimum default configuration:
resolve: `gatsby-source-wordpress`,
options: {
url: `https://wpgatsbydemo.wpengine.com/graphql`,
},
Here's one of the starters with a valid and running WordPress GraphQL configuration: https://www.gatsbyjs.com/starters/gatsbyjs/gatsby-starter-wordpress-blog