Closed mmazurowski closed 4 years ago
Do you get similar errors if you query your wordpress / wp-graphql instance outside of Gatsby? You can try this through https://github.com/wp-graphql/wp-graphiql (adding graphiql
"ide" to your wordpress admin panel).
There are few possibilities I can see:
enum
with no values in itgatsby-source-graphql
) might not handle this correctly.Other question - you mentioned cleaning cache - does it mean just deleting .cache
directory? Or did you update packages as well? (there might be regression that happened somewhere)
Using 3rd party query "ide" works properly, I can query and get proper results. I've deleted .cache directory, node modules and package.lock file, I've also downgraded gatsby-source-graphqpl from 2.3.2 to 2.1.25 as this was suggested in other issue.
For now, no improvements.
@ktw-studio the LanguageCodeEnum
isn't from core WPGraphQL, but is from the WPGraphQL for PolyLang plugin.
I believe you should be able to configure the PolyLang plugin with some languages and this error will go away?
From what I can tell, it looks like the enum doesn't have any values set if Polylang hasn't been configured with any languages.
I've opened an issue on the WPGraphQL for Polylang repo here: https://github.com/valu-digital/wp-graphql-polylang/issues/20
I've also opened a PR (https://github.com/valu-digital/wp-graphql-polylang/pull/21) to address this and ensure there's a default value (the site's locale) in case no languages are set up yet. I believe the PR should address this, but @esamattis (creator of WPGraphQL for Polylang) should probably weigh in and make sure the PR makes sense.
@ktw-studio So, I setup WP PolyLang locally along with WPGraphQL for Polylang, and I've confirmed this is indeed the issue.
If you setup some languages under the PolyLang Languages page (/wp-admin/admin.php?page=mlang
) the error will go away.
Here, we can see no languages setup in Polylang:
And if I query the Enum using GraphQL introspection in WPGraphiQL, we can see there are no values:
This is where Gatsby is getting tripped up.
If I add a language to PolyLang:
And Query the Enum again, there are values:
The PR also addresses this by adding a default language. This will allow users that have installed PolyLang and WPGraphQL for Polylang to not run into issues before going through the Polylang setup.
Here, I have no languages again:
And with the code changed in my PR, I can query the Schema and we will see a default value from the locale of the site:
@ktw-studio I'm going to close this issue in favor of the issue/PR I've opened on the WPGraphQL for Polylang repo:
@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!
:)
Description
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
`
const allPages = [] let pageNumber = 0 const itemsPerPage = 10
/**
@returns {Promise}
*/
module.exports = async ({ actions, graphql, reporter }, options) => {
/**
first
controls how many items toafter
controls where to start in@returns {Promise<>} / const fetchPages = async (variables) => /**
/**
/**
fetch page ${pageNumber} of pages...
) return fetchPages({ first: itemsPerPage, after: endCursor }) }/**
/**
fetchPages
method which will get us allwpPages && wpPages.map((page) => { let pagePath =
${page.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(R) Core(TM) 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