Gatsby-source-wordpress-experimental: Preview not updating on published post and 404 on draft post

Created on 21 Jul 2020  路  14Comments  路  Source: gatsbyjs/gatsby-source-wordpress-experimental

WP draft preview has stopped after latest update with following behaviours:

  1. Draft post will return with Gatsby development 404 error
  2. Published post will return with preview, but non-published changes are not reflected in preview.

gatsby-source-wordpress-experimental: 1.0.7
wp-gatsby: 0.4.13
WP: 5.4.2
WP GraphQL: 0.10.3

Tested on Gatsby Cloud and locally through ngrok debug setup.

upstream

All 14 comments

Thanks @hazuremon , I've had a couple other reports of preview issues as well. I'll be spending some time today manually testing preview to see what kinds of issues I run into. What version of Gatsby are you on?

Hi @hazuremon can you try updating to the latest version of the source plugin to see if this issue is fixed for you?

Thanks!

Had the same issue. With the update to the current version 1.1.1 it's working again.

Good to hear @philmuze , I believe this issue was originally that the preview API in WPGQL changed substantially and my initial updates to work with that change didn't work as well as I thought. @hazuremon , are you able to update to the latest and check if it's working for you?

Hi @TylerBarnes, I have just test it with the following setup, but behaviours remain the same for both draft and published posts.

gatsby-source-wordpress-experimental: 1.1.1
wp-gatsby: 0.4.14
WP: 5.4.2
WP GraphQL: 0.10.3
Gatsby CLI version: 2.12.66
Gatsby version: 2.24.11

Draft post: Gatsby Cloud didn't get trigger when previewing a draft post
Published post: Gatsby Cloud rebuilds when requesting a preview, but not updated with any unpublished content.

Hi @hazuremon , I just ran into this as well on WPE hosting. It looks like they add define( 'WP_POST_REVISIONS', FALSE ); by default which should store 1 autosave and allow preview to still function. But there may be a WPGraphQL bug that prevents preview from working in this situation. I was able to get it working by removing that line (define( 'WP_POST_REVISIONS', FALSE );) from wp-config.php.

We're tracking progress on this potential bug at https://github.com/wp-graphql/wp-graphql/issues/1408

You might be able to get your preview working by checking if this is set in your wp-config and removing it.

Thanks @TylerBarnes.

I have test it locally using ngrok debugging setup and got the draft preview to work, but came across another behaviour.

On draft post, the first preview request will return with a 404 error, only when the second preview request will be able to return with preview.

For published post, the first request will return a preview without any unpublished changes, only with second preview request it's updated with changes in the post.

I haven't have a chance to update the config on WPE (and I am using WP Engine for WP hosting), but will follow up with any results.

@hazuremon this 404 bug is a known issue that I'm working on. The problem is that WP doesn't know wether the preview page has been created or not yet. To get around this for now, opening a new draft will send an empty preview, then hopefully by the time you've actually pressed "preview", that preview page has already been created and isn't a 404.

I'm working on adding a new endpoint to Gatsby localhost:8000/__wpgatsby which will allow WP to ask Gatsby if the preview is ready or not. Until it's ready it will display a loading spinner in the WP preview template, then unveil the preview when it's ready. This should fix both issues as most likely the second case you mentioned is due to preview sometimes being a bit slower than expected.

You can follow along on progress at https://github.com/gatsbyjs/gatsby-source-wordpress-experimental/issues/97

I'll keep this issue open for now, but it appears this is an upstream WPGQL bug. Anyone else who has this issue can follow the steps above until https://github.com/wp-graphql/wp-graphql/issues/1408 is resolved.

I reached out to WPE support, they mentioned the setting (define( 'WP_POST_REVISIONS', FALSE );) will get added back once the site gets regenerate on their end (daily I was told). They suggest to set revision to 1, so that it won't be removed.

@TylerBarnes Preview works on WPE once revision is set with one.

@hazuremon thanks for letting us know, that's great info. We should get this fixed in WPGraphQL core soon so it's not an issue

Hi @TylerBarnes, I notice draft preview hasn't been working and is getting a 404 error. I have test it through Gatsby Cloud and locally through ngrok debug setup.

Published post preview works though.

gatsby-source-wordpress-experimental: 1.3.6
wp-gatsby: 0.4.16
WP: 5.5
WP GraphQL: 0.12.1
Gatsby CLI version: 2.12.88
Gatsby version: 2.24.50

Hey Tyler, I'm also getting a 404 on drafts using the latest version of everything

@joperron , the preview logic is being rewritten to work more consistently. You can follow that work in https://github.com/gatsbyjs/gatsby-source-wordpress-experimental/issues/97

I'm going to close this issue as that work will fix the issues being experienced here. Thanks everyone

Was this page helpful?
0 / 5 - 0 ratings