gatsby: [gatsby-source-wordpress] TypeError: Cannot destructure property 'fields' of 'nodesType' as it is undefined

Preliminary Checks

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

Most upvoted comments

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 assumptions gatsby-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 approved

Hey 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:

Successfully published:
 - gatsby-source-wordpress@7.2.1
lerna success published 1 package

and

Successfully published:
 - gatsby-source-wordpress@6.24.2
lerna success published 1 package

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?

9:11:01 AM: error UNHANDLED REJECTION Interface field WpEdgeType.node expected but WpEnqueuedScriptConnectionEdgeType does not provide it.
9:11:01 AM: Interface field WpEdgeType.node expected but WpEnqueuedStylesheetConnectionEdgeType does not provide it.
9:11:01 AM: Interface field WpEdgeType.node expected but WpActionMonitorActionConnectionEdgeType does not provide it.
9:11:01 AM: Interface field WpEdgeType.node expected but WpPluginConnectionEdgeType does not provide it.
9:11:01 AM: Interface field WpEdgeType.node expected but WpThemeConnectionEdgeType does not provide it.
9:11:01 AM: 
9:11:01 AM: 
9:11:01 AM:   Error: Interface field WpEdgeType.node expected but WpEnqueuedScriptConnection  EdgeType does not provide it.
9:11:01 AM:   Interface field WpEdgeType.node expected but WpEnqueuedStylesheetConnectionEdg  eType does not provide it.
9:11:01 AM:   Interface field WpEdgeType.node expected but WpActionMonitorActionConnectionEd  geType does not provide it.
9:11:01 AM:   Interface field WpEdgeType.node expected but WpPluginConnectionEdgeType does n  ot provide it.
9:11:01 AM:   Interface field WpEdgeType.node expected but WpThemeConnectionEdgeType does no  t provide it.
9:11:01 AM:   
9:11:01 AM:   - graphql-runner.ts:129 GraphQLRunner.validate
9:11:01 AM:     [repo]/[gatsby]/src/query/graphql-runner.ts:129:14
9:11:01 AM:   
9:11:01 AM:   - graphql-runner.ts:218 GraphQLRunner.query
9:11:01 AM:     [repo]/[gatsby]/src/query/graphql-runner.ts:218:49
9:11:01 AM:   
9:11:01 AM:   - create-graphql-runner.ts:57 
9:11:01 AM:     [repo]/[gatsby]/src/bootstrap/create-graphql-runner.ts:57:8
9:11:01 AM:   
9:11:01 AM:   - create-pages-from-collection-builder.js:45 createPagesFromCollectionBuilder
9:11:01 AM:     [repo]/[gatsby-plugin-page-creator]/create-pages-from-collection-builder.js:    45:13
9:11:01 AM: Creating deploy upload records
9:11:01 AM:   
9:11:01 AM:   - create-page-wrapper.js:43 createPage
9:11:01 AM:     [repo]/[gatsby-plugin-page-creator]/create-page-wrapper.js:43:76
9:11:01 AM:   
9:11:02 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:11:01 AM:   - gatsby-node.js:135 
9:11:01 AM:     [repo]/[gatsby-plugin-page-creator]/gatsby-node.js:135:41
9:11:01 AM:   
9:11:01 AM:   - Array.forEach
9:11:01 AM:   
9:11:01 AM:   - gatsby-node.js:134 Object.createPagesStatefully
9:11:01 AM:     [repo]/[gatsby-plugin-page-creator]/gatsby-node.js:134:11
9:11:01 AM:   
9:11:01 AM: 
9:11:01 AM: not finished createPagesStatefully - 0.188s
9:11:01 AM: ​
9:11:01 AM: ────────────────────────────────────────────────────────────────
9:11:01 AM:   "build.command" failed                                        
9:11:01 AM: ─────────────────────────────────────────────────────────

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