After cleaning cache ""gatsby-node.js" threw an error while running the createPagesStatefully lifecycle"
See original GitHub issueDescription
Hey,
Just today my gatsby installation stopped working (I’ve cleaned cache). I get the following error:
Enum type WPGraphQL_LanguageCodeEnum must define one or more values.
Steps to reproduce
Clear steps describing how to reproduce the issue. Please please please link to a demo project if possible, this makes your issue much easier to diagnose (seriously).
My gatsby-node.js:
` const createPages = require(“./create/createPages”)
exports.createPagesStatefully = async ({ graphql, actions, reporter }, options) => { await createPages({ actions, graphql, reporter }, options) } `
And createPages: ` const pageTemplate = require.resolve(“…/src/templates/page.js”)
const GET_PAGES = query GET_PAGES($first:Int $after:String) { wpgraphql { pages( first: $first after: $after # This will make sure to only get the parent nodes and no children where: { parent: null } ) { pageInfo { hasNextPage endCursor } nodes { id title pageId uri isFrontPage } } } }
const allPages = [] let pageNumber = 0 const itemsPerPage = 10
/**
- This is the export which Gatbsy will use to process.
- @param { actions, graphql }
- @returns {Promise<void>} */ module.exports = async ({ actions, graphql, reporter }, options) => {
/**
-
This is the method from Gatsby that we’re going
-
to use to create pages in our static site. / const { createPage } = actions /*
-
Fetch pages method. This accepts variables to alter
-
the query. The variable
first
controls how many items to -
request per fetch and the
after
controls where to start in -
the dataset.
-
@param variables
-
@returns {Promise<*>} / const fetchPages = async (variables) => /*
- Fetch pages using the GET_PAGES query and the variables passed in.
/
await graphql(GET_PAGES, variables).then(({ data }) => {
/*
- Extract the data from the GraphQL query results */ const { wpgraphql: { pages: { nodes, pageInfo: { hasNextPage, endCursor }, }, }, } = data
/**
- Map over the pages for later creation */ nodes && nodes.map((pages) => { allPages.push(pages) })
/**
- If there’s another page, fetch more
- so we can have all the data we need.
*/
if (hasNextPage) {
pageNumber++
reporter.info(
fetch page ${pageNumber} of pages...
) return fetchPages({ first: itemsPerPage, after: endCursor }) }
/**
- Once we’re done, return all the pages
- so we can create the necessary pages with
- all the data on hand. */ return allPages })
- Fetch pages using the GET_PAGES query and the variables passed in.
/
await graphql(GET_PAGES, variables).then(({ data }) => {
/*
/**
- Kick off our
fetchPages
method which will get us all - the pages we need to create individual pages. */ await fetchPages({ first: itemsPerPage, after: null }).then((wpPages) => {
wpPages && wpPages.map((page) => {
let pagePath = `${page.uri}`
/**
* If the page is the front page, the page path should not be the uri,
* but the root path '/'.
*/
if(page.isFrontPage) {
pagePath = '/'
}
createPage({
path: pagePath,
component: pageTemplate,
context: {
id: String(page.pageId)
},
})
reporter.info(`page created: ${pagePath}`)
})
reporter.info(`# -----> PAGES TOTAL: ${wpPages.length}`)
}) } `
2 hours ago everything worked properly, any idea what could have happend?
Expected result
Gatsby develop and build commands will work properly.
Actual result
Nothing to add than description above, sorry.
Environment
System: OS: macOS 10.15.4 CPU: (12) x64 Intel® Core™ i7-8850H CPU @ 2.60GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 13.10.1 - /usr/local/bin/node npm: 6.14.4 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/bin/python Browsers: Chrome: 80.0.3987.163 Firefox: 70.0.1 Safari: 13.1 npmPackages: gatsby: ^2.20.12 => 2.20.12 gatsby-image: ^2.3.1 => 2.3.1 gatsby-plugin-manifest: ^2.3.3 => 2.3.3 gatsby-plugin-offline: ^3.1.2 => 3.1.2 gatsby-plugin-react-helmet: ^3.2.1 => 3.2.1 gatsby-plugin-sharp: ^2.5.3 => 2.5.3 gatsby-source-graphql: ^2.1.25 => 2.3.2 gatsby-transformer-sharp: ^2.4.3 => 2.4.3 npmGlobalPackages: gatsby-cli: 2.11.5
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
@jasonbahl You were absolutely right, seems this issue was not directly caused by gatsby itself. Thank you all for your help and sorry for the trouble! Be safe, be in health, keep on being awesome!
😃
@ktw-studio I’m going to close this issue in favor of the issue/PR I’ve opened on the WPGraphQL for Polylang repo: