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] fails with an error after a Woocommerce product is edited in Wordpress. #32712

Closed
2 tasks done
Petermhen opened this issue Aug 5, 2021 · 7 comments
Closed
2 tasks done
Labels
stale? Issue that may be closed soon due to the original author not responding any more. topic: source-wordpress Related to Gatsby's integration with WordPress type: bug An issue or pull request relating to a bug in Gatsby

Comments

@Petermhen
Copy link

Petermhen commented Aug 5, 2021

Preliminary Checks

Description

I'm using the gatsby-source-wordpress Gatsby plugin along with WPGatsby, WooGraphQL & Woocommerce Wordpress plugins to source Woocommerce product data into Gatsby.

After building the website using "gatsby develop", on editing a Woocommerce product or creating a new Woocommerce product in the Wordpress Admin, gatsby-source-wordpress fails with an error on attempting to auto-rebuild the Woocommerce product change using cache.

On ending the development server process and running "gatsby develop" again, the site builds successfully but any changes made to Woocommerce products or new products created aren't shown.

The changes to existing Woocommerce products & newly created products show up when products are queried in the GraphiQL IDE in the Wordpress Admin interface (so it doesn't seem to be an issue with the WooGraphQL plugin), but not when products are queried in the Gatsby site's GraphiQL IDE (http://localhost:8000/___graphql).

The only way to have changes to Woocommerce products or newly created products show up on the site and in Gatsby's GraphiQL IDE is to rebuild the site from scratch without cache, by running "gatsby clean && gatsby develop" after every Woocommerce product update.

In Production on Netlify the same happens. Product changes trigger the Netlify build hook, which successfully completes the build, but no edits to existing products or newly created products show up in the new build. The only solution is to clear the cache and do a lengthy rebuild from scratch using the "Clear cache and rebuild" button in Netlify's interface.

gatsby-source-wordpress detects changes and rebuilds using cache successfully (changes show up on the website) on edits to any other content in Wordpress, such as Wordpress posts, Advanced custom fields, Pages,etc. The error & failure to build changes unless cache is cleared only happens on updates to Woocommerce products.

Auto Rebuilding on detected changes to Woocommerce products previously worked fine until I updated my Gatsby packages & Wordpress plugins & neglected to test this feature. I've tried retracing my steps to figure out what update may have introduced the problem, but I've been unsuccessful so far.

I've tried updating all packages to the latest versions & I still get the error. I then updated all packages to their unstable "next" versions, but I get the same error still.

Reproduction Link

https://codesandbox.io/s/wizardly-boyd-jev0o?file=/gatsby-config.js

Steps to Reproduce

I've been able to reproduce this error using the Gatsby starter template with minimal changes to it along with a fresh Wordpress installation.

The CodeSandbox reproduction link that I've given reproduces the error, however you'll need to swap out the wordpress server link in "gatsby-config.js" with your Wordpress server & make an edit to a Woocommerce product to trigger a rebuild, at which point you should see the error.

  1. In Wordpress, install the following plugins (I've specified the version that I'm using): Woocommerce (5.5.2), WP Gatsby (1.0.11), WP GraphQL (1.5.7), WPGraphQL WooCommerce (0.10.2)
  2. In Wordpress, Create a basic product in Woocommerce, with at least a name.
  3. Create Gatsby project with the Starter template.
  4. Install the Gatsby plugin gatsby-source-wordpress using npm.
  5. In gatsby-config.js, under "plugins", add an entry for gatsby-source-wordpress, including the URL of your Wordpress site.
  6. In the "index.js" page, add a Graphql query to get products from Woocommerce, and render the name of a product to the page.
  7. Start the development server via running "gatsby develop" in the console
  8. After the development server has started & the site is displaying in the browser, edit the name of the Woocommerce product you created in Wordpress. The stated error should show up.
    ...

Expected Result

Gatsby-source-wordpress detects the change to the Woocommerce product & rebuilds only the edits made to the Woocommerce product using cache. The product changes show up on the website after rebuild completes.

Actual Result

Gatsby-source-wordpress fails with an error after a change is made to a Woocommerce product or a new product is created. The changes to the Woocommerce product do not show up on the website.

Console log showing the error:

    success Checking for changed pages - 0.002s
    success update schema - 0.872s
    success onPreExtractQueries - 0.002s
    success extract queries from components - 0.908s
    success write out requires - 0.003s
    success run static queries - 0.017s - 1/1 57.88/s
    success run page queries - 0.476s - 5/5 10.50/s
    success Writing page-data.json files to public directory - 0.046s - 4/19 413.20/s
    success  gatsby-source-wordpress  diff schemas - 0.774s
    success  gatsby-source-wordpress  ingest WPGraphQL schema - 1.570s
    success createSchemaCustomization - 1.833s
    success  gatsby-source-wordpress  fetch root fields - 0.553s
    ⠀
    info  gatsby-source-wordpress  update product Sealy Holly Hills Eurotop test11 (#32)
    ⠀
    success  gatsby-source-wordpress  pull updates since last build - 2.024s
    success Checking for changed pages - 0.001s
    success source and transform nodes - 2.136s

    error Missing onError handler for invocation 'building-schema', error was 'Error: Cannot find ObjectTypeComposer with name WpProduct'. Stacktrace was 'Error: Cannot find ObjectTypeComposer with name WpProduct
    at SchemaComposer.getOTC (/home/peter/Documents/Current Projects/adfoam/sleep-solutions-website/node_modules/graphql-compose/lib/SchemaComposer.js:557:11)
    at forEach (/home/peter/Documents/Current Projects/adfoam/sleep-solutions-website/node_modules/gatsby/src/schema/infer/index.js:30:37)
    at Array.forEach (<anonymous>)
    at addInferredTypes (/home/peter/Documents/Current Projects/adfoam/sleep-solutions-website/node_modules/gatsby/src/schema/infer/index.js:27:13)
    at updateSchemaComposer (/home/peter/Documents/Current Projects/adfoam/sleep-solutions-website/node_modules/gatsby/src/schema/schema.js:177:9)
    at buildSchema (/home/peter/Documents/Current Projects/adfoam/sleep-solutions-website/node_modules/gatsby/src/schema/schema.js:68:3)
    at build (/home/peter/Documents/Current Projects/adfoam/sleep-solutions-website/node_modules/gatsby/src/schema/index.js:110:18)
    at buildSchema (/home/peter/Documents/Current Projects/adfoam/sleep-solutions-website/node_modules/gatsby/src/services/build-schema.ts:19:3)'

Environment

System:
    OS: Linux 5.4 Linux Mint 20 (Ulyana)
    CPU: (4) x64 Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.17.2 - ~/.nvm/versions/node/v14.17.2/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.2/bin/npm
  npmPackages:
    gatsby: ^3.12.0-next.0 => 3.12.0-next.0
    gatsby-plugin-sharp: ^3.12.0-next.0 => 3.12.0-next.0
    gatsby-source-wordpress: ^5.12.0-next.0 => 5.12.0-next.0
    gatsby-transformer-sharp: ^3.10.0 => 3.10.0
  npmGlobalPackages:
    gatsby-cli: 3.8.0

Config Flags

None

@Petermhen Petermhen added the type: bug An issue or pull request relating to a bug in Gatsby label Aug 5, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 5, 2021
@LekoArts LekoArts added topic: source-wordpress Related to Gatsby's integration with WordPress and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Aug 9, 2021
@AudunBeck
Copy link

@Petermhen Did you find any workaround for this?

@Petermhen
Copy link
Author

Petermhen commented Aug 31, 2021

@Petermhen Did you find any workaround for this?

Unfortunately I've not found any way to get gatsby-source-wordpress to update products without clearing the cache.

The only possible solution that I've found so far is reverting to the older "gatsby-source-woocommerce" plugin & manually triggering rebuilds. I think this is what last worked for me. Still have to verify though.

@github-actions
Copy link

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! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Sep 21, 2021
@Petermhen
Copy link
Author

Hiya!

This issue has gone quiet. Spooky quiet. ghost

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! musclepurple_heart

Replying to keep open as issue is still unresolved and is a major problem.

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Oct 12, 2021
@github-actions
Copy link

github-actions bot commented Nov 1, 2021

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! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Nov 1, 2021
@github-actions
Copy link

Hey again!

It’s been 60 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to comment on this issue or create a new one if you need anything else.
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 again for being part of the Gatsby community! 💪💜

@Petermhen
Copy link
Author

Bump. This is a critical error as updating Woocommerce products isn't exactly an obscure use case. Any progress on this issue by chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more. 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

No branches or pull requests

3 participants