gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

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

Closed kyle-tully closed 1 year ago

kyle-tully commented 1 year ago

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

graphql url is reachable and graphiql ide returns correct post data for a basic query.

Fresh Gatsby install with Wordpress.

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

LekoArts commented 1 year ago

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! πŸ’œ

tsamantanis commented 1 year ago

Experiencing the same. Cannot reproduce on a fresh install

metanite commented 1 year ago

also happens in v6.24.1

tsamantanis commented 1 year ago

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

REDSoftwareRasmus commented 1 year ago

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 commented 1 year ago

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

REDSoftwareRasmus commented 1 year ago

Yeah that's what I did as well πŸ˜„ @turbz

tsamantanis commented 1 year ago

Downgrading WPGraphQL does fix the issue @REDSoftwareRasmus. Thanks!

LekoArts commented 1 year ago

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

TylerBarnes commented 1 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 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!

kyle-tully commented 1 year ago

Thanks, this fixed the issue for me too.

Downgraded to Version 1.12.2 of WPGraphQL plugin fixed it.

corbin-c commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

amcc commented 1 year ago

I've installed the alpha above and get the error below during the develop process, I had to upgrade everything to Gatsby v5 in order to get this far :

success building schema - 0.521s

 ERROR #11321  API.NODE.EXECUTION

"gatsby-node.js" threw an error while running the createPages lifecycle:

Interface field WpEdgeType.node expected but WpEnqueuedScriptConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpEnqueuedStylesheetConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpActionMonitorActionConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpPluginConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpThemeConnectionEdgeType does not provide it.

   7 |   const { createPage } = actions;
   8 |
>  9 |   const result = await graphql(`
     |                        ^
  10 |     {
  11 |       allWpStudent {
  12 |         edges {

File: gatsby-node.js:9:24

Tried commenting out gatsby-node.js, but still get the following error:

 ERROR  UNKNOWN

Missing onError handler for invocation 'extracting-queries', error was 'Error: Interface field WpEdgeType.node expected but
WpEnqueuedScriptConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpEnqueuedStylesheetConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpActionMonitorActionConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpPluginConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpThemeConnectionEdgeType does not provide it.'. Stacktrace was 'Error: Interface field
WpEdgeType.node expected but WpEnqueuedScriptConnectionEdgeType does not provide it.

happy to paste in the much fuller errors if needed

TylerBarnes commented 1 year ago

@amcc is there a repo or api endpoint I can use to reproduce it?

amcc commented 1 year ago

@TylerBarnes sent in the wp-graphql slack (hope that's ok, rather than here)

TylerBarnes commented 1 year ago

@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

TylerBarnes commented 1 year ago

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
aaronjtonner commented 1 year ago

Sorry but I'm not quite sure what I need to do on my end to fix this but I'm still getting the errors:

image

TylerBarnes commented 1 year ago

@aaronjtonner if you upgrade to the latest version of gatsby-source-wordpress it should go away

aaronjtonner commented 1 year ago

Thanks Tyler. That got rid of those errors and caused a new one, haven't seen any fixes for this and no idea where it's coming from: image

TylerBarnes commented 1 year ago

I haven't seen that before either. I recommend opening a new issue :)

amcc commented 1 year ago

I saw that too. Only on gatsby cloud, not a local build. Still built though

On Wed, 7 Dec 2022 at 00:00, Tyler Barnes @.***> wrote:

I haven't seen that before either. I recommend opening a new issue :)

β€” Reply to this email directly, view it on GitHub https://github.com/gatsbyjs/gatsby/issues/37114#issuecomment-1340175879, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA4EX7TMWDRQ3EKDZM64SDWL7HQTANCNFSM6AAAAAASOETQOE . You are receiving this because you were mentioned.Message ID: @.***>

Haldaug commented 1 year ago

I still get the same error as @amcc after upgrading to gatsby-source-wordpress@7.2.1. The error message is the same:

ERROR #11321  API.NODE.EXECUTION
"gatsby-node.js" threw an error while running the createPages lifecycle:
Interface field WpEdgeType.node expected but WpEnqueuedScriptConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpEnqueuedStylesheetConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpActionMonitorActionConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpPluginConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpThemeConnectionEdgeType does not provide it.

Using the gatsby-source-wordpress@7.3.0-alpha-wpgql-thirteen.20 version I get this error instead:

Error executing the GraphQL query inside gatsby-plugin-sitemap:
 Field "nodeType" is not defined by type "WpContentNodeFilterInput".
  GraphQLError: Field "nodeType" is not defined by type "WpContentNodeFilterInput".
TylerBarnes commented 1 year ago

@Haldaug the error from the canary was because I needed to remove the nodeType field to support the latest WPGraphQL version. You should be able to use the __typename field instead. That's odd that the canary doesn't have the other errors though while the newly published version does πŸ€” I'll look into that and see if I can figure out what's going on

TylerBarnes commented 1 year ago

@Haldaug any way I can use your repo to reproduce the problem?

Haldaug commented 1 year ago

I've invited you to view my repo, @TylerBarnes.

TylerBarnes commented 1 year ago

Thanks @Haldaug !

aaronjtonner commented 1 year ago

I still get the same error as @amcc after upgrading to gatsby-source-wordpress@7.2.1. The error message is the same:

ERROR #11321  API.NODE.EXECUTION
"gatsby-node.js" threw an error while running the createPages lifecycle:
Interface field WpEdgeType.node expected but WpEnqueuedScriptConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpEnqueuedStylesheetConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpActionMonitorActionConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpPluginConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpThemeConnectionEdgeType does not provide it.

I'm getting this same error

tsamantanis commented 1 year ago

I am also getting this error now. I think this issue can be reopened as it is caused by the latest update.

I still get the same error as @amcc after upgrading to gatsby-source-wordpress@7.2.1. The error message is the same:

ERROR #11321  API.NODE.EXECUTION
"gatsby-node.js" threw an error while running the createPages lifecycle:
Interface field WpEdgeType.node expected but WpEnqueuedScriptConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpEnqueuedStylesheetConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpActionMonitorActionConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpPluginConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpThemeConnectionEdgeType does not provide it.

I'm getting this same error

DanicaTo commented 1 year ago

Me too.

I am also getting this error now. I think this issue can be reopened as it is caused by the latest update.

I still get the same error as @amcc after upgrading to gatsby-source-wordpress@7.2.1. The error message is the same:

ERROR #11321  API.NODE.EXECUTION
"gatsby-node.js" threw an error while running the createPages lifecycle:
Interface field WpEdgeType.node expected but WpEnqueuedScriptConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpEnqueuedStylesheetConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpActionMonitorActionConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpPluginConnectionEdgeType does not provide it.
Interface field WpEdgeType.node expected but WpThemeConnectionEdgeType does not provide it.

I'm getting this same error

TylerBarnes commented 1 year ago

I narrowed down the issue, turns out the problem is I split the fix into 2 PR's. The first PR was the actual fix and the second was supposed to just be updating the integration tests. This one line should've been in the first PR but was in the second. I marked that second PR to be backported and have a hotfix release so once that's released it should be fixed. Sorry for the mistake folks! For now the canary version is identical to what's about to be released.

TylerBarnes commented 1 year ago

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.

TylerBarnes commented 1 year ago

It seems the removal of the nodeType field in the latest version is problematic for some folks. I'll add it back in. The alternative is to use the contentType field but it seems enough folks are using nodeType that it can't be removed without needing to change a lot of site queries which is a big problem.

Apologies for the rocky time here everyone. We're getting close to this problem being over, but there's a little more to go.

aaronjtonner commented 1 year ago

Thanks Tyler :)

TylerBarnes commented 1 year ago

The Gatsby 4 version was just published as gatsby-source-wordpress@6.25.1. I tested this on a site I could reproduce the issues on and it's working great.

This new version doesn't include a nodeType field fix though, that's coming soon.

TylerBarnes commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

TylerBarnes commented 1 year ago

@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 commented 1 year ago

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

TylerBarnes commented 1 year ago

Thanks @aaronjtonner

TylerBarnes commented 1 year ago

@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 commented 1 year ago

Thanks Tyler, that fixed those errors!

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

TylerBarnes commented 1 year ago

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 commented 1 year ago

v12.3 There is only version 12.2

TylerBarnes commented 1 year ago

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!