Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
kyle-tully opened this issue Nov 29, 2022 · 62 comments · Fixed by #37134
Closed
2 tasks done
Labels
topic: source-plugins Relates to the Gatsby source plugins (e.g. -filesystem) topic: source-wordpress Related to Gatsby's integration with WordPress type: bug An issue or pull request relating to a bug in Gatsby

Comments

@kyle-tully
Copy link

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

@kyle-tully kyle-tully added the type: bug An issue or pull request relating to a bug in Gatsby label Nov 29, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Nov 29, 2022
@LekoArts LekoArts added status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: source-wordpress Related to Gatsby's integration with WordPress topic: source-plugins Relates to the Gatsby source plugins (e.g. -filesystem) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Nov 29, 2022
@LekoArts
Copy link
Contributor

Hi!

Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.

If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.

Thanks for using Gatsby! 💜

@LekoArts LekoArts changed the title [gatsby-source-wordpress] ERROR #gatsby-source-wordpress_112003 [gatsby-source-wordpress] TypeError: Cannot destructure property 'fields' of 'nodesType' as it is undefined Nov 29, 2022
@tsamantanis
Copy link

Experiencing the same. Cannot reproduce on a fresh install

@metanite
Copy link

also happens in v6.24.1

@tsamantanis
Copy link

Seems like it can be an issue caused by the latest update of the WPGRAPHQL plugin

@REDSoftwareRasmus
Copy link

Also experienced this issue this morning.

+1 up on your suggestion @tsamantanis
"Seems like it can be an issue caused by the latest update of the WPGRAPHQL plugin"

For a temporary fix before this is resolved I downloaded an older version of the WPGraphQL plugin v12.3 here and replaced the existing v13.0 on our Wordpress instance. Seems to havre resolved the issue.

So the new WPGraphQL version seems to be the cultprit here.

@turbz
Copy link

turbz commented Nov 29, 2022

@REDSoftwareRasmus I actually downgraded to v12.3 and the issue was resolved.

@REDSoftwareRasmus
Copy link

Yeah that's what I did as well 😄 @turbz

@tsamantanis
Copy link

Downgrading WPGraphQL does fix the issue @REDSoftwareRasmus. Thanks!

@LekoArts
Copy link
Contributor

Please open an issue on the WPGraphQL GitHub then. Thanks!

@LekoArts LekoArts closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2022
@LekoArts LekoArts added type: upstream Issues outside of Gatsby's control, caused by dependencies and removed status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. labels Nov 29, 2022
@TylerBarnes TylerBarnes reopened this Nov 29, 2022
@TylerBarnes
Copy link
Contributor

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!

@TylerBarnes TylerBarnes removed the type: upstream Issues outside of Gatsby's control, caused by dependencies label Nov 29, 2022
@kyle-tully
Copy link
Author

Thanks, this fixed the issue for me too.

Downgraded to Version 1.12.2 of WPGraphQL plugin fixed it.

@corbin-c
Copy link

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
Copy link
Contributor

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

@TylerBarnes
Copy link
Contributor

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

@TylerBarnes
Copy link
Contributor

TylerBarnes commented Dec 2, 2022

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

@TylerBarnes
Copy link
Contributor

TylerBarnes commented Dec 7, 2022

I released a canary that adds back the nodeType field here gatsby-source-wordpress@7.3.0-alpha-wpgql-thirteen.26. I marked the PR to be backported in a hotfix release for Gatsby 4 and 5 versions, so that should be released tomorrow. I'll drop a message here with the final fixed versions when it's released

@hamiltonbrooke
Copy link

hamiltonbrooke commented Dec 8, 2022

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

@TylerBarnes
Copy link
Contributor

Two new versions with the nodeType field fix were published earlier today: gatsby-source-wordpress@7.2.3 and gatsby-source-wordpress@6.25.2.

@hamiltonbrooke are you able to share your WPGrphQL /graphql endpoint with me so I can reproduce the issue? My email is tyler@gatsbyjs.com if you don't want to share it publicly

@aaronjtonner
Copy link

aaronjtonner commented Dec 8, 2022

Hi Tyler, I was not previously getting this error until after the update. This is the same for all ACF queries:
image

@TylerBarnes
Copy link
Contributor

@aaronjtonner are you able to send me your WPGraphQL api endpoint so I can reproduce the problem? Our integration tests do test using wp-graphql-acf but perhaps there's some case we're not testing, or our test site doesn't have the same setup as you

@aaronjtonner
Copy link

Sure, here's the endpoint: https://staging.innerspiritphoto.com/graphql

@TylerBarnes
Copy link
Contributor

Thanks @aaronjtonner

@TylerBarnes
Copy link
Contributor

TylerBarnes commented Dec 8, 2022

@aaronjtonner that might be due to a change in how WPGraphQL 1.13.0+ works. The field is named aCF_BooksPage, not ACF_BooksPage (notice the first letter is lowercase).

In WPGraphQL:

{
  pages {
    nodes {
      aCF_BooksPage {
        fieldGroupName
      }
    }
  }
}

in Gatsby:

{
  allWpPage {
    nodes {
      aCF_BooksPage {
        fieldGroupName
      }
    }
  }
}

@aaronjtonner
Copy link

Thanks Tyler, that fixed those errors!

Still dealing with a few other errors that might be due to something else.

@TylerBarnes
Copy link
Contributor

I believe the last remaining issue is the problem you mentioned @hamiltonbrooke but since I'm not able to reproduce it I'm not able to fix it. Is anyone else seeing those same errors on the latest versions?

@edsonJordan
Copy link

v12.3
There is only version 12.2

@TylerBarnes
Copy link
Contributor

TylerBarnes commented Jan 3, 2023

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!

@salmanamemon
Copy link

salmanamemon commented Jan 4, 2023

+1 same issue with new update version 13 , we downgraded to 12.2 and now works.

@TylerBarnes
Copy link
Contributor

@salmanamemon thanks for sharing, which issue are you having? A description of it + reproduction steps will help a lot.
thanks!

@salmanamemon
Copy link

Hi @TylerBarnes, It is almost the same as Jason Bahl mentioned.

Description
Updated a few days ago to 1.13.7 and I wasn't able to start my Gatsby app, not even in develop mode.

Tried to disable all plugins and the error still remained. Rolled back to 1.12.2, and everything works fine again. After re-activating all other plugins everything works fine

Steps to reproduce
"gatsby develop"

Additional context
Detailed error:

TypeError: Cannot destructure property 'fields' of 'nodesType' as it is undefined.
at generateNodeQueriesFromIngestibleFields (/xxx/gatsbyapp/node_modules/gatsby-source-wordpress/src/steps/ingest-remote-schema/build-queries-from-introspection/generate-queries-from-ingestable-types.js:155:13)
at buildNodeQueries
(/xxx/gatsbyapp/node_modules/gatsby-source-wordpress/src/steps/ingest-remote-schema/build-queries-from-introspection/build-node-queries.js:25:25)
at runSteps (/xxx/gatsbyapp/node_modules/gatsby-source-wordpress/src/utils/run-steps.ts:41:9)
at runSteps (/xxx/gatsbyapp/node_modules/gatsby-source-wordpress/src/utils/run-steps.ts:43:9)
at ingestRemoteSchema (/xxx/gatsbyapp/node_modules/gatsby-source-wordpress/src/steps/ingest-remote-schema/index.js:49:5)
at runSteps (/xxx/gatsbyapp/node_modules/gatsby-source-wordpress/src/utils/run-steps.ts:41:9)
at runAPI (/xxx/gatsbyapp/node_modules/gatsby/src/utils/api-runner-node.js:487:16)

WPGraphQL Version
1.13.0

WordPress Version
6.1.1

PHP Version
8.1

Additional enviornment details
No response

Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have disabled ALL plugins except for WPGraphQL.
Yes
My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

@TylerBarnes
Copy link
Contributor

@salmanamemon did you upgrade to the latest version of gatsby-source-wordpress?

@salmanamemon
Copy link

No gatbsy-source-wordpress is the same
"node_modules/gatsby-source-wordpress": {
"version": "6.24.0",

@TylerBarnes
Copy link
Contributor

@salmanamemon upgrade to the latest 6.x.x version of source-wordpress and it should start working. (yarn install gatsby-source-wordpress@^6.0.0 / npm install gatsby-source-wordpress@^6.0.0)

@byebyers
Copy link

I am having the same issue here when updating PHP to 8.1. Is that part of the problem?

gatsby-source-wordpress version: 6.25.3
WPGraphQL version: 1.13.7
WordPress version: 6.1.1

None of the above solutions worked. Right now I have a working site working with PHP 7.4 and will stick with that for now.

@TylerBarnes
Copy link
Contributor

@byebyers I haven't heard reports of that yet, that's odd. Are you saying when you're on the latest versions of those plugins it works until you switch to PHP 8.1?

mehov pushed a commit to redakt-eu/editjournal-gatsbyjs that referenced this issue Feb 3, 2023
Fixes Cannot destructure property 'fields' of 'nodesType' as it is undefined

gatsbyjs/gatsby#37114
mehov pushed a commit to redakt-eu/editjournal-gatsbyjs that referenced this issue Feb 3, 2023
Fixes Cannot destructure property 'fields' of 'nodesType' as it is undefined

gatsbyjs/gatsby#37114
@byebyers
Copy link

byebyers commented Feb 9, 2023

@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.

@aaronjtonner
Copy link

Hi @TylerBarnes, not sure if this is the correct place for this, but I'm running into problems in local development. Everything is set up properly and I'm using local flywheel. Would this have anything to do with version updates?
image

@Daw-St
Copy link

Daw-St commented Mar 6, 2023

Hi @TylerBarnes, not sure if this is the correct place for this, but I'm running into problems in local development. Everything is set up properly and I'm using local flywheel. Would this have anything to do with version updates? image

Have you managed to solve the issue? Could you share versions of WP GraphQL, WP Gatsby and gatsby-source-wordpress? I'm struggling with the same issue.
cc @TylerBarnes

@TylerBarnes
Copy link
Contributor

@Daw-St that's unrelated to this issue, can you open a GH discussion instead?

@gatsbyjs gatsbyjs locked as resolved and limited conversation to collaborators Mar 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: source-plugins Relates to the Gatsby source plugins (e.g. -filesystem) topic: source-wordpress Related to Gatsby's integration with WordPress type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.