gatsby: [gatsby-source-wordpress] TypeError: Cannot destructure property 'fields' of 'nodesType' as it is undefined
Preliminary Checks
- This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
- This issue is not a question, feature request, RFC, or anything other than a bug report directly related to Gatsby. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions
Description
Trying to setup Gatsby with Wordpress.
“Encountered a critical error when running the buildNodeQueries build step.”
“TypeError: Cannot destructure property ‘fields’ of ‘nodesType’ as it is undefined. at generateNodeQueriesFromIngestibleFields”
Reproduction Link
na
Steps to Reproduce
Fresh WP install with latest plugin versions of
- WP Gatsby
- WP GraphQL
graphql url is reachable and graphiql ide returns correct post data for a basic query.
Fresh Gatsby install with Wordpress.
- gatsby-source-wordpress url is set in gatsby-config.js
Run gatsby develop and get the above error.
Expected Result
success
Actual Result
error
Environment
System:
OS: macOS 12.6
CPU: (4) x64 Intel(R) Core(TM) i5-7600 CPU @ 3.50GHz
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.11.0 - ~/.nodenv/shims/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.19.2 - ~/.nodenv/shims/npm
Browsers:
Chrome: 107.0.5304.110
Edge: 107.0.1418.62
Firefox: 103.0.2
Safari: 16.1
npmPackages:
gatsby: ^5.2.0 => 5.2.0
gatsby-plugin-image: ^3.2.0 => 3.2.0
gatsby-plugin-manifest: ^5.2.0 => 5.2.0
gatsby-plugin-sharp: ^5.2.0 => 5.2.0
gatsby-plugin-sitemap: ^6.2.0 => 6.2.0
gatsby-source-filesystem: ^5.2.0 => 5.2.0
gatsby-source-wordpress: ^7.2.0 => 7.2.0
gatsby-transformer-sharp: ^5.2.0 => 5.2.0
npmGlobalPackages:
gatsby-cli: 5.2.0
Config Flags
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 62 (30 by maintainers)
Commits related to this issue
- Require gatsby-source-wordpress ^6.25.3 Fixes Cannot destructure property 'fields' of 'nodesType' as it is undefined https://github.com/gatsbyjs/gatsby/issues/37114 — committed to redakt-eu/editjournal-gatsbyjs by deleted user a year ago
- Require gatsby-source-wordpress ^6.25.3 Fixes Cannot destructure property 'fields' of 'nodesType' as it is undefined https://github.com/gatsbyjs/gatsby/issues/37114 — committed to redakt-eu/editjournal-gatsbyjs by deleted user a year ago
Hey everyone, the errors here come from upgrading WPGraphQL but are due to how
gatsby-source-wordpress
works. There were some breaking changes in the latest version of WPGraphQL that aren’t noticeable for most users but break the assumptionsgatsby-source-wordpress
makes about WPGraphQL’s schema.I’m currently working on a fix for it and I’ll post an update here when I have a new version of
gatsby-source-wordpress
for you.Thanks!
I have a fix which is forward/backwards compatible with WPGraphQL! I released it as a canary here
gatsby-source-wordpress@7.3.0-alpha-wpgql-13.36
. I’ll also flag the PR as a hotfix so it’s released asap after being approvedHey folks, it’s taking a little longer than expected but I want to drop an update here. I’ve fixed all of the issues that were failing builds and causing connections to break. I’m now working through integration test failures on older versions of WPGraphQL. Once I can be sure the changes I made wont break sites on earlier versions of WPGraphQL I’ll be able to ship the fix
Thanks, this fixed the issue for me too.
Downgraded to Version 1.12.2 of WPGraphQL plugin fixed it.
Yesterday I identified the problem, I’m just reading through the code right now and updating it with the fix, as the fix needs to be applied in multiple places. I’ll have a PR up today
@amcc thanks for the repro!
Turns out I published the last canary incorrectly, or from the wrong commit. This new canary version fixes the issue
gatsby-source-wordpress@7.3.0-alpha-wpgql-thirteen.20
This is published in:
and
Exact same issue here after WPGraphQL update to 1.13.x, downgrading fixed it. Using an outdated version of a plugin in a production environment isn’t a suitable long-term solution though.
@TylerBarnes I still need to troubleshoot a few things but at first glance, that is what it looks like on my end. I will follow up on this thread once I have more info.
No gatbsy-source-wordpress is the same “node_modules/gatsby-source-wordpress”: { “version”: “6.24.0”,
I’m going to close this since I haven’t heard any more reports recently. If anyone is still running into problems please respond here with reproduction steps or open a new issue and I can help you out. Thanks everyone for your patience on this issue and for helping me reproduce bugs!
Thanks Tyler, that fixed those errors!
Still dealing with a few other errors that might be due to something else.
Hi Tyler,
Just upgraded to version 7.2.2. Builds are failing on Netlify.
Is this related?
Thanks Tyler 😃
Gatsby 5 version of source-wordpress with the full fix is published as
gatsby-source-wordpress@7.2.2
. I verified this fixes the issue on a site I reproduced the problem on, so should actually be good this time. The v4 compatible version isn’t published just yet but should be soon.I’ve invited you to view my repo, @TylerBarnes.
@TylerBarnes sent in the wp-graphql slack (hope that’s ok, rather than here)
Seems like it can be an issue caused by the latest update of the WPGRAPHQL plugin