Gatsby Preview for Drupal is not working for Draft status

We are using Gatsby Preview with Drupal Headless. We found Preview only works when the content status is Published in Drupal. We want Preview to work for Draft status as well. Not sure if this is possible. The interesting thing is , when we change content status to Draft, only Preview build is triggered, but the content is not getting updated.

Is this a limitation of Gatsby Preview for Drupal ? We are using Drupal 10.

Thanks for writing in! Drupal Previews in Gatsby aren’t limited to published content. You’ll definitely want to ensure you’ve configured the Gatsby Drupal module per this documentation, namely the “Gatsby Application” section:

  1. Update gatsby-node.js. Typically you will want to use the preview variable in conditionals that involve createPage calls. This will ensure that the preview environment will create unpublished and draft pages.

Please reach out with any questions!

I’m resurrecting this thread because I’ve read the documentation you’ve linked but can’t get it to work. Could you please provide a specific code example that demonstrates how to implement the following?

Typically you will want to use the preview variable in conditionals that involve createPage calls.

I do have the GATSBY_IS_PREVIEW environment variable defined in my local environment as well as on our Netlify site, but I can’t see how to correctly use it in createPage calls. Again, a specific code example would help immensely.

Just to confirm @tqureshi-uog, which preview are you talking about? The thread was about Gatsby Cloud and with that sunsetting in the next 2 weeks, I don’t think helping about it makes sense. Netlify doesn’t support Gatsby Previews.

All I’m looking for at this point is a way to get unpublished and draft content to show up on the Netlify site we’re using for preview purposes. I was hoping some of the information on this thread could help with that, i.e. get a build working that shows draft content even without using Gatsby Cloud preview.

Is it at all possible, or no?

If you’re asking about this: gatsby-source-drupal | Gatsby (gatsbyjs.com), it’s not possible.

A useful next step for setting this up would be to install a module that works well with Netlify Build Webhooks; Netlify doesn’t have a native Drupal module similar to Gatsby and so we can’t officially recommend one, but in testing the Build Hooks module I’ve found it works well for this purpose, and ships with a Netlify submodule.

That submodule allows you to configure different frontend environments (like a preview environment) that can get rebuilt on content changes, cron jobs, etc. You’ll need to supply a PAT and the API ID for the site you’re using for previews, but once you do, you should be able to make changes to your unpublished content and see those changes on your preview site.

1 Like

hey @hiteshdev
I wrote my little blog here to guild how to integrate live preview Draft content for Gatsby and Wordpress on Netlify, I think it will related your issue, hope it help: https://trilm95.com/blog/live-preview-gatsby-netlify