gatsbyjs / gatsby

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

The remote WPGraphQL schema hasn't changed but local generated type definitions have. #37931

Closed daniel-layers closed 6 months ago

daniel-layers commented 1 year ago

Preliminary Checks

Description

Fresh WordPress Installation with the following plugins installed:

advanced-custom-fields-pro event-tickets gravityforms learndash-hub sfwd-lms the-events-calendar woocommerce wp-gatsby wp-graphql wp-graphql-acf-master wp-graphql-cors-master wp-graphql-cpt-master wp-graphql-gravity-forms-develop wp-graphql-jwt-authentication-develop wp-graphql-woocommerce-develop

GraphQL Endpoint targeted: https://learngatsby.wpengine.com/graphql

Error occurs on first run of npm run develop.

Error is attached as TXT.

gatsby-source-terminal-error.txt

Reproduction Link

https://github.com/daniel-layers/learn-gatsby

Steps to Reproduce

  1. Install WordPress plugins in WordPress
  2. Create project with gatsby new
  3. Use just wordpress and javascript no additional options selected on install
  4. Run npm run develop
  5. Error occurs

Expected Result

Site to launch and be ready for use.

Actual Result

Failed to build.

Environment

System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M2 Pro
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.15.0 - /usr/local/bin/node
    npm: 9.5.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 112.0.5615.49
    Safari: 16.3
  npmPackages:
    gatsby: ^5.8.1 => 5.8.1
    gatsby-plugin-image: ^3.8.0 => 3.8.0
    gatsby-plugin-sharp: ^5.8.1 => 5.8.1
    gatsby-source-wordpress: ^7.8.0 => 7.8.0
    gatsby-transformer-sharp: ^5.8.0 => 5.8.0
  npmGlobalPackages:
    gatsby-cli: 5.8.0

Config Flags

No response

rmeghji commented 1 year ago

also having this issue! any word on when this may be patched/how to work around it?

marlenesco commented 1 year ago

I have the same issue using docker, wordpress and mysql, can someone help us on this mess?

info  gatsby-source-wordpress  Panicking due to inconsistent schema customization. 
Turn this into a warning by setting process.env.WP_INCONSISTENT_SCHEMA_WARN to a string of "true"

ERROR #gatsby-source-wordpress_112004  PLUGIN

gatsby-source-wordpress  The remote WPGraphQL schema hasn't changed but local
generated type definitions have. This is a bug, please open an issue on Github
and include the following text..

Missing type names: WpService
WpServiceConnectionEdgeType
WpServiceConnectionType
WpServiceConnectionPageInfoType
TylerBarnes commented 1 year ago

@marlenesco or @rmeghji are you able to provide a repro? For now you can work around it by setting process.env.WP_INCONSISTENT_SCHEMA_WARN = 'true' and it'll likely be fine. I added the error message there because I saw the issue before but had a hard time reproducing it reliably. You'll see query errors at build time if it's really a problem for your site, but without this error it's not clear why those query errors are happening if they do

tony-gutierrez commented 1 year ago

Same issue with gatsby-source-contentful. Local schema gets corrupted over time and have to clear cache to correct.

marlenesco commented 1 year ago

Hi @TylerBarnes, thank you for your answer, I've tried to put the process.env.WP_INCONSISTENT_SCHEMA_WARN = 'true' but I have the same issue. I've tried to search for this exact value "WP_INCONSISTENT_SCHEMA_WARN" in google and other search engine, but what I retrieve is nothing, and this is strange because this term should be found in some repository or codes, but it is not.

In the next days I'll put a repo online to try to fix this strange behaviour. Cheers

TylerBarnes commented 1 year ago

@marlenesco this is where it's checked in gatsby-source-wordpress https://github.com/gatsbyjs/gatsby/blob/fd4d702bf3e969bed1289e62106314be9fd41345/packages/gatsby-source-wordpress/src/steps/create-schema-customization/helpers.js#L438

therealgilles commented 1 year ago

I don't want to hijack this thread but I'm seeing something similar with gatsby-source-wordpress:

info  gatsby-source-wordpress  Panicking due to inconsistent schema customization. Turn this into a warning by setting process.env.WP_INCONSISTENT_SCHEMA_WARN to a string of "true"

 ERROR #gatsby-source-wordpress_112004  PLUGIN

 gatsby-source-wordpress  The remote WPGraphQL schema hasn't changed but local generated type definitions have. This is a bug, please open an issue on Github and include the following text..

Changed type defs:

Typename WpProductToProductAttributeConnectionType diff:
 {
   kind: "OBJECT"
   config: {
     name: "WpProductToProductAttributeConnectionType"
     fields: {
       nodes: {
         type: "[WpProductAttribute!]!"
         description: "The nodes of the connection, without the edges"
       }
       pageInfo: {
         type: "WpProductToProductAttributeConnectionPageInfoType!"
         description: "Information about pagination in a connection."
       }
     }
     description: "Connection between the Product type and the ProductAttribute type"
     extensions: {
       infer: false
     }
     interfaces: [
+      "WpProductAttributeConnectionType"
       "WpConnectionType"
     ]
   }
 }

Typename WpProductAttributeConnectionType diff:
+{
+  kind: "INTERFACE"
+  config: {
+    name: "WpProductAttributeConnectionType"
+    fields: {
+      nodes: {
+        type: "[WpProductAttribute!]!"
+        description: "A list of connected ProductAttribute Nodes"
+      }
+      pageInfo: {
+        type: "WpProductAttributeConnectionPageInfoType!"
+        description: "Information about pagination in a connection."
+      }
+    }
+    extensions: {
+      infer: false
+    }
+    interfaces: [
+      "WpConnectionType"
+    ]
+  }
+}

Typename WpProductAttributeConnectionEdgeType diff:
+{
+  kind: "INTERFACE"
+  config: {
+    name: "WpProductAttributeConnectionEdgeType"
+    fields: {
+      node: {
+        type: "WpProductAttribute!"
+        description: "The connected ProductAttribute Node"
+      }
+    }
+    extensions: {
+      infer: false
+    }
+    interfaces: [
+      "WpEdgeType"
+    ]
+  }
+}

Typename WpProductToGlobalProductAttributeConnectionType diff:
 {
   kind: "OBJECT"
   config: {
     name: "WpProductToGlobalProductAttributeConnectionType"
     fields: {
       nodes: {
         type: "[WpGlobalProductAttribute!]!"
         description: "The nodes of the connection, without the edges"
       }
       pageInfo: {
         type: "WpProductToGlobalProductAttributeConnectionPageInfoType!"
         description: "Information about pagination in a connection."
       }
     }
     description: "Connection between the Product type and the GlobalProductAttribute type"
     extensions: {
       infer: false
     }
     interfaces: [
+      "WpGlobalProductAttributeConnectionType"
       "WpConnectionType"
     ]
   }
 }

Typename WpGlobalProductAttributeConnectionType diff:
+{
+  kind: "INTERFACE"
+  config: {
+    name: "WpGlobalProductAttributeConnectionType"
+    fields: {
+      nodes: {
+        type: "[WpGlobalProductAttribute!]!"
+        description: "A list of connected GlobalProductAttribute Nodes"
+      }
+      pageInfo: {
+        type: "WpGlobalProductAttributeConnectionPageInfoType!"
+        description: "Information about pagination in a connection."
+      }
+    }
+    extensions: {
+      infer: false
+    }
+    interfaces: [
+      "WpConnectionType"
+    ]
+  }
+}

Typename WpGlobalProductAttributeConnectionEdgeType diff:
+{
+  kind: "INTERFACE"
+  config: {
+    name: "WpGlobalProductAttributeConnectionEdgeType"
+    fields: {
+      node: {
+        type: "WpGlobalProductAttribute!"
+        description: "The connected GlobalProductAttribute Node"
+      }
+    }
+    extensions: {
+      infer: false
+    }
+    interfaces: [
+      "WpEdgeType"
+    ]
+  }
+}

Typename WpProductToLocalProductAttributeConnectionType diff:
 {
   kind: "OBJECT"
   config: {
     name: "WpProductToLocalProductAttributeConnectionType"
     fields: {
       nodes: {
         type: "[WpLocalProductAttribute!]!"
         description: "The nodes of the connection, without the edges"
       }
       pageInfo: {
         type: "WpProductToLocalProductAttributeConnectionPageInfoType!"
         description: "Information about pagination in a connection."
       }
     }
     description: "Connection between the Product type and the LocalProductAttribute type"
     extensio

...
[Diff exceeded 5000 characters and was truncated]

I have the following setup in gatsby-config.ts:

        schema: {
          typePrefix: `Wp`,
          timeout: 4 * 60 * 1000,
        },
        includedRoutes: ['**/pages'],
        excludedRoutes: [
          '**/posts',
          '**/media',
          '**/categories',
          '**/tags',
          '**/taxonomies',
          '**/users',
        ],
        type: {
          __all: {
            limit: process.env.NODE_ENV === `development` ? 100 : 5000,
          },
          Post: {
            limit: 20,
            where: 'categoryNotIn: "retired"',
          },
          MediaItem: {
            localFile: {
              maxFileSizeBytes: 1048576 * 20, // 20 MB
            },
            excludeFieldNames: [
              'contentNodes',
              'seo',
              'ancestors',
              'author',
              'template',
              'lastEditedBy',
              'authorDatabaseId',
              'authorId',
              'contentTypeName',
              'dateGmt',
              'desiredSlug',
              'enclosure',
              'isContentNode',
              'isTermNode',
              'modified',
              'modifiedGmt',
              'parentDatabaseId',
              'parentId',
              'srcSet',
              'parent',
              'children',
            ],
          },
          Comment: {
            limit: 0,
          },
          Tag: {
            limit: 0,
          },
          User: {
            limit: 0,
          },
          UserRole: {
            limit: 0,
          },
          Customer: {
            limit: 0,
          },
          Coupon: {
            limit: 0,
          },
          Order: {
            limit: 0,
          },
          PaRole: {
            limit: 0,
          },
          Product: {
            limit: 0,
            where: 'categoryNotIn: "retired"',
          },
          ProductTag: {
            limit: 0,
          },
          ProductType: {
            limit: 0,
          },
          ProductCategory: {
            limit: 0,
          },
          ProductAttribute: {
            limit: 0,
          },
          GlobalProductAttribute: {
            limit: 0,
          },
          PaymentGateway: {
            limit: 0,
          },
          Refund: {
            limit: 0,
          },
          ShippingClass: {
            limit: 0,
          },
          ShippingMethod: {
            limit: 0,
          },
          TaxRate: {
            limit: 0,
          },
          VisibleProduct: {
            limit: 0,
          },
          Organizer: {
            limit: 0,
          },
          Venue: {
            limit: 0,
          },
          ContentType: {
            limit: 0,
          },
          Category: {
            // limit: 0,
          },
          Taxonomy: {
            limit: 0,
          },
        },
        develop: {
          hardCacheMediaFiles: true,
        },
        debug: {
          graphql: {
            onlyReportCriticalErrors: false,
            showQueryVarsOnError: true,
            showQueryOnError: true,
            writeQueriesToDisk: true,
          },
        },
TatsumaNakano commented 1 year ago

I was able to work this around by turning all plugins off and turning them back all together at once. (When I turn it on individually it caused the same problem again🤷). Also, I change the endpoint back to /graphql, instead of a custom one. I know it sounds weird and not exactly sure what fixed this but worked for me, so I wanted to share.

brandonbarringer commented 1 year ago

I'm getting a similar error to @therealgilles, when I set WP_INCONSISTENT_SCHEMA_WARN to true, I get the following errors:

 ERROR #11321  API.NODE.EXECUTION

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

Interface field WpConnectionType.nodes expected but WpTaxonomyConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpContentTypeConnectionType does not provide it.

Interface field WpOneToOneConnectionType.node expected but WpContentNodeToEditLockConnectionEdgeType
does not provide it.

Interface field WpEdgeType.node expected but WpContentNodeToEditLockConnectionEdgeType does not provide
 it.

Type WpUserConnectionEdgeType must define one or more fields.

Interface field WpConnectionType.nodes expected but WpCommentConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpPostConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpCategoryConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpPostFormatConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpTagConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpUserRoleConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpMediaItemToCommentConnectionType does not provide
 it.

Interface field WpConnectionType.nodes expected but WpUserConnectionType does not provide it.

  4 |   const { createPage } = actions
  5 |   const pageTemplatePath = path.resolve('./src/templates/page.js')
> 6 |   const result = await graphql(`
    |                        ^
  7 |     {
  8 |       allWpPage {
  9 |         edges {

File: gatsby-node.js:6:24

  Error: Interface field WpConnectionType.nodes expected but WpTaxonomyConnectionType does not provide
  it.
  Interface field WpConnectionType.nodes expected but WpContentTypeConnectionType does not provide it.
  Interface field WpOneToOneConnectionType.node expected but WpContentNodeToEditLockConnectionEdgeType
  does not provide it.
  Interface field WpEdgeType.node expected but WpContentNodeToEditLockConnectionEdgeType does not provi
  de it.
  Type WpUserConnectionEdgeType must define one or more fields.
  Interface field WpConnectionType.nodes expected but WpCommentConnectionType does not provide it.
  Interface field WpConnectionType.nodes expected but WpPostConnectionType does not provide it.
  Interface field WpConnectionType.nodes expected but WpCategoryConnectionType does not provide it.
  Interface field WpConnectionType.nodes expected but WpPostFormatConnectionType does not provide it.
  Interface field WpConnectionType.nodes expected but WpTagConnectionType does not provide it.
  Interface field WpConnectionType.nodes expected but WpUserRoleConnectionType does not provide it.
  Interface field WpConnectionType.nodes expected but WpMediaItemToCommentConnectionType does not provi
  de it.
  Interface field WpConnectionType.nodes expected but WpUserConnectionType does not provide it.

  - graphql-runner.ts:129 GraphQLRunner.validate
    [lt.laureltrust.ui]/[gatsby]/src/query/graphql-runner.ts:129:22

  - graphql-runner.ts:218 GraphQLRunner.query
    [lt.laureltrust.ui]/[gatsby]/src/query/graphql-runner.ts:218:49

  - create-graphql-runner.ts:57 apply
    [lt.laureltrust.ui]/[gatsby]/src/bootstrap/create-graphql-runner.ts:57:8

  - create-pages.ts:36 wrappedGraphQL
    [lt.laureltrust.ui]/[gatsby]/src/services/create-pages.ts:36:47

  - gatsby-node.js:6 Object.exports.createPages
    /Users/brandonbarringer/Desktop/sites/www/lt.laureltrust.ui/gatsby-node.js:6:24

  - api-runner-node.js:509 runAPI
    [lt.laureltrust.ui]/[gatsby]/src/utils/api-runner-node.js:509:37

failed createPages - 0.123s
success createPagesStatefully - 0.074s
info Total nodes: 74, SitePage nodes: 4 (use --verbose for breakdown)
success Checking for changed pages - 0.001s
success write out redirect data - 0.023s
success Build manifest and related icons - 0.149s
success onPostBootstrap - 0.154s
info bootstrap finished - 9.905s
success onPreExtractQueries - 0.002s

 ERROR  UNKNOWN

Missing onError handler for invocation 'extracting-queries', error was 'Error: Interface field
WpConnectionType.nodes expected but WpTaxonomyConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpContentTypeConnectionType does not provide it.

Interface field WpOneToOneConnectionType.node expected but WpContentNodeToEditLockConnectionEdgeType
does not provide it.

Interface field WpEdgeType.node expected but WpContentNodeToEditLockConnectionEdgeType does not provide
 it.

Type WpUserConnectionEdgeType must define one or more fields.

Interface field WpConnectionType.nodes expected but WpCommentConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpPostConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpCategoryConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpPostFormatConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpTagConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpUserRoleConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpMediaItemToCommentConnectionType does not provide
 it.

Interface field WpConnectionType.nodes expected but WpUserConnectionType does not provide it.'.
Stacktrace was 'Error: Interface field WpConnectionType.nodes expected but WpTaxonomyConnectionType
does not provide it.

Interface field WpConnectionType.nodes expected but WpContentTypeConnectionType does not provide it.

Interface field WpOneToOneConnectionType.node expected but WpContentNodeToEditLockConnectionEdgeType
does not provide it.

Interface field WpEdgeType.node expected but WpContentNodeToEditLockConnectionEdgeType does not provide
 it.

Type WpUserConnectionEdgeType must define one or more fields.

Interface field WpConnectionType.nodes expected but WpCommentConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpPostConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpCategoryConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpPostFormatConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpTagConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpUserRoleConnectionType does not provide it.

Interface field WpConnectionType.nodes expected but WpMediaItemToCommentConnectionType does not provide
 it.

Interface field WpConnectionType.nodes expected but WpUserConnectionType does not provide it.
    at assertValidSchema (/Users/brandonbarringer/Desktop/sites/www/lt.laureltrust.ui/node_modules/grap
hql/type/validate.js:59:11)
    at validate (/Users/brandonbarringer/Desktop/sites/www/lt.laureltrust.ui/node_modules/graphql/valid
ation/validate.js:63:35)
    at extractOperations (/Users/brandonbarringer/Desktop/sites/www/lt.laureltrust.ui/node_modules/gats
by/src/query/query-compiler.js:214:18)
    at processQueries (/Users/brandonbarringer/Desktop/sites/www/lt.laureltrust.ui/node_modules/gatsby/
src/query/query-compiler.js:170:45)
    at compile (/Users/brandonbarringer/Desktop/sites/www/lt.laureltrust.ui/node_modules/gatsby/src/que
ry/query-compiler.js:80:19)
    at updateStateAndRunQueries (/Users/brandonbarringer/Desktop/sites/www/lt.laureltrust.ui/node_modul
es/gatsby/src/query/query-watcher.ts:236:40)
    at extractQueries (/Users/brandonbarringer/Desktop/sites/www/lt.laureltrust.ui/node_modules/gatsby/
src/services/extract-queries.ts:18:3)'
ptoly commented 1 year ago

I solved the problem with # gatsby clean, then # gatsby develop

macphersonj commented 1 year ago

I solved the problem with # gatsby clean, then # gatsby develop

Does it come back on a subsequent gatsby develop? I can silence it, but need to clean & develop more often than not.

ptoly commented 1 year ago

I solved the problem with # gatsby clean, then # gatsby develop

Does it come back on a subsequent gatsby develop? I can silence it, but need to clean & develop more often than not.

For me it occurs whenever I change the schema on my WordPress backend, where I'm adding new custom fields and content types. Basically it appears that Gatsby doesn't do diligence on schema changes during the develop ramp up and quits. Once I have the schema set, I don't usually have to run clean. Although it's kind of today's version of Ctrl Alt Delete...

brandonbarringer commented 1 year ago

For me this seems to occur with with newer versions of the wp graphql plugin. It works fine if I roll back to v1.12.2

axonaris commented 1 year ago

Same here - error after wpgraphql plugin update, works fine if I roll back to 1.13.10. Clearing cache didn't help.

WPGraphQL ver. 1.14.9 gatsby-source-wordpress@7.11.0

ibjorn commented 1 year ago

Been sitting with this problem for months now and unable to find answers. Now there's the push from Gatsby Cloud to Netlify and time is running out. But unable to move my site until I can resolve this.

*update

I came across this solution: https://github.com/gatsbyjs/gatsby/issues/37729#issuecomment-1571092100

I ended up removing the type: {...} configuration entirely as I was only using it for excludes anyway. All good.

dlucenario commented 1 year ago

rm -rf .cache worked for me.

brandonbarringer commented 9 months ago

Any updates here?

brandonbarringer commented 8 months ago

continuing my check every month. Any solutions?

ekon97 commented 7 months ago

@pieh Can you check this?

brandonbarringer commented 7 months ago

Site maintenance day again. Any updates here?

TylerBarnes commented 7 months ago

https://github.com/gatsbyjs/gatsby/pull/38856

github-actions[bot] commented 6 months ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

TylerBarnes commented 6 months ago

This should be fixed in the latest release 🎉 thanks @pieh