gatsbyjs / gatsby

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

Gatsby-source-wordpress: ERROR #11321 after upgrading WPGraphQL to 1.14.0 #37729

Closed Haldaug closed 1 year ago

Haldaug commented 1 year ago

Preliminary Checks

Description

An error occurs during parallel query running after upgrading the Word Press plugin WPGraphQL to 1.14.0, failing the build. I suspect that the update included some breaking changes for gatsby-source-wordpress.

Everything works as expected after downgrading back to 1.13.1

Reproduction Link

/

Steps to Reproduce

  1. Upgrade WPGraphQL from 1.13.10 to 1.14.0
  2. Run a clean build

Expected Result

A successful build

Actual Result

I get the following error: ERROR #11321 API.NODE.EXECUTION "gatsby-node.js" threw an error while running the createPages lifecycle: Interface field WpConnectionType.nodes expected but WpEnqueuedScriptConnectionType does not provide it. Interface field WpConnectionType.nodes expected but WpEnqueuedStylesheetConnectionType does not provide it. Interface field WpConnectionType.nodes expected but WpActionMonitorActionConnectionType does not provide it. Interface field WpConnectionType.nodes expected but WpPluginConnectionType does not provide it. Interface field WpConnectionType.nodes expected but WpThemeConnectionType does not provide it.

You can find an example of a failed build here: https://www.gatsbyjs.com/dashboard/2ed6779b-2fc9-4c4f-b7db-3aac04ebbde8/sites/cef43953-59d5-4aa4-862b-7a8d057182ef/builds/697abd16-42d4-46d8-a1a3-d80b30d3471d/details?returnTo=%2Fdashboard%2F2ed6779b-2fc9-4c4f-b7db-3aac04ebbde8%2Fsites%2Fcef43953-59d5-4aa4-862b-7a8d057182ef%2FcmsPreview#rawLogs

Environment

System:
    OS: Linux 5.10 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-1260P
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 19.3.0 - ~/.nvm/versions/node/v19.3.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.2.0 - ~/.nvm/versions/node/v19.3.0/bin/npm
  npmPackages:
    gatsby: ^5.0.1 => 5.7.0 
    gatsby-plugin-algolia: ^1.0.0 => 1.0.3 
    gatsby-plugin-exclude: ^1.0.2 => 1.0.2 
    gatsby-plugin-feed: ^5.1.0 => 5.7.0 
    gatsby-plugin-gatsby-cloud: ^5.1.0 => 5.7.0 
    gatsby-plugin-google-gtag: ^5.1.0 => 5.7.0 
    gatsby-plugin-image: ^3.1.0 => 3.7.0 
    gatsby-plugin-manifest: ^5.1.0 => 5.7.0 
    gatsby-plugin-no-sourcemaps: ^5.1.0 => 5.7.0 
    gatsby-plugin-perf-budgets: ^0.0.18 => 0.0.18 
    gatsby-plugin-postcss: ^6.1.0 => 6.7.0 
    gatsby-plugin-react-svg: ^3.3.0 => 3.3.0 
    gatsby-plugin-sharp: ^5.1.0 => 5.7.0 
    gatsby-plugin-sitemap: ^6.1.0 => 6.7.0 
    gatsby-plugin-webpack-bundle-analyser-v2: ^1.1.30 => 1.1.30 
    gatsby-source-filesystem: ^5.1.0 => 5.7.0 
    gatsby-source-wordpress: ^7.2.3 => 7.7.0 
    gatsby-transformer-sharp: ^5.1.0 => 5.7.0 
  npmGlobalPackages:
    gatsby-cli: 5.3.1

Config Flags

No response

mrcsmcln commented 1 year ago

This exact issue is happening for me as well.

mikeriley131 commented 1 year ago

Same, I just started getting this yesterday after making no changes other than the WP GraphQL upgrade to 1.14.0. Rolling back to 1.13.10 resolves the issue.

kylelondonuk commented 1 year ago

Same issue for me. Will roll back to 1.13.10

TylerBarnes commented 1 year ago

It appears to be a problem with the way source-wordpress is caching the remote schema. Certain types are omitted by default (because they don't work in Gatsby) but those types are only being omitted on the initial build and then are included in cached builds. When they're included they then break the schema because they're not properly implementing their interfaces since those types weren't supposed to exist anyway.

I've added some logic to catch when the generated schema doesn't match the previous schema and fail the build with a helpful error and type diffs, so that this will be more obvious in the future if it happens again. I'm also fixing the issue though and I should have a PR up tomorrow or the next day

TylerBarnes commented 1 year ago

I have a PR open fixing this ☝️ and there's a canary available as gatsby-source-wordpress@7.8.0-alpha-wp-inconsistent-schema.29 for anyone who needs it asap!

TylerBarnes commented 1 year ago

I marked the PR to be back ported for Gatsby 4 & 5 but check my previous comment for anyone who needs the fix right away

DanielRiveraHQ commented 1 year ago

I tried this, and the issue persists. On a fresh build, some nodes are missing, but if I go to Wordpress and save the content missing while I'm running gatsby development, it appears. @TylerBarnes

TylerBarnes commented 1 year ago

@DanielRiveraHQ are you able to share a reproduction with me? Sharing it privately works too (tyler@gatsbyjs.com)

dishpanda commented 1 year ago

Thanks for the canary fix, worked for me!

philJohnson commented 1 year ago

@TylerBarnes I'm also getting this issue. Looking at getting a reproduction however I've found that the issue occurs specifically when I exclude types in my config. I've attached the config below.

{
      resolve: `gatsby-source-wordpress`,
      options: {
        url: process.env.GATSBY_GRAPHQL_API_URL,
        schema: {
          timeout: 60000,
          perPage: 50,
          requestConcurrency: 15,
          previewRequestConcurrency: 5
        },
        html: {
          useGatsbyImage: false,
          createStaticFiles: false
        },
        type: {
          MediaItem: {
            createFileNodes: false
          },
           UserRole: {
             exclude: true
           },
           Comment: {
             exclude: true
          }
        },
        develop: {
          hardCacheMediaFiles: true
        }
      }
    },

If I include comments and user roles then I no longer get an issue.

DanielRiveraHQ commented 1 year ago

@philJohnson I'll check if that solution works! 🙏

ibjorn commented 1 year ago

@TylerBarnes I'm also getting this issue. Looking at getting a reproduction however I've found that the issue occurs specifically when I exclude types in my config. I've attached the config below.

{
      resolve: `gatsby-source-wordpress`,
      options: {
        url: process.env.GATSBY_GRAPHQL_API_URL,
        schema: {
          timeout: 60000,
          perPage: 50,
          requestConcurrency: 15,
          previewRequestConcurrency: 5
        },
        html: {
          useGatsbyImage: false,
          createStaticFiles: false
        },
        type: {
          MediaItem: {
            createFileNodes: false
          },
           UserRole: {
             exclude: true
           },
           Comment: {
             exclude: true
          }
        },
        develop: {
          hardCacheMediaFiles: true
        }
      }
    },

If I include comments and user roles then I no longer get an issue.

Removing type: {...} entirely worked for me. I was only using it for excludes anyway.

maghaffar commented 5 months ago

I have a PR open fixing this ☝️ and there's a canary available as gatsby-source-wordpress@7.8.0-alpha-wp-inconsistent-schema.29 for anyone who needs it asap!

I am still getting this error in 2024. Did'nt you resolved the issue?. I have upgraded my WPGraphql version and after that I am getting the error. Do we have a permanent solution?

maghaffar commented 5 months ago

@TylerBarnes Please help me in resolving this. I want a permanent solution rather than changing my gatsby-source-wordpress version to the specific version you mentioned above

TylerBarnes commented 5 months ago

@maghaffar I'm not maintaining this repo anymore but the fix was released in Gatsby 4 and 5 nearly a year ago

maghaffar commented 5 months ago

@TylerBarnes Can you please mention who is maintaining the repo. I think that the it is needed to fix this again with WPGraphql 1.24.0.