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

[feat]: add Gatsby Cloud functionality and "hot reloading" #15

Open
DSchau opened this issue Jun 20, 2019 · 2 comments
Open

[feat]: add Gatsby Cloud functionality and "hot reloading" #15

DSchau opened this issue Jun 20, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@DSchau
Copy link

DSchau commented Jun 20, 2019

Summary

Right now -- this plugin has several areas that could be augmented to better support the Gatsby ecosystem, particularly with Gatsby Cloud. Specifically:

  1. Images are sourced from static.ghost.org rather than tying into createRemoteFileNode functionality (See Add gatsby-transformer-sharp support #5)
  2. No ability to "live update" data from Ghost, e.g. when content is created, updated or deleteed

Let's focus on #2 for this issue.

Live Updating

Gatsby Cloud uses webhooks to synchronize content from the CMS with the running Gatsby application. Ghost already supports webhooks, so we're part of the way there towards supporting hot reloading of data.

How it works under the hood is that the sourceNodes function in gatsby-node.js is re-invoked whenever we receive a web hook. What's missing now is some way to incrementally know what has been changed, and how to take the current state of the GraphQL schema and update it to match the new Ghost data.

To best support plugin authors, we've put together an Integration Guide that outlines several approaches in updating a plugin to have great Gatsby Cloud support. The eventual result of this work would be:

  1. This plugin has a way to request changed data
  2. This plugin (when sourceNodes is invoked) calls createNode, deleteNode, and touchNode to get the schema consistent with Ghost

@JohnONolan question -- does the webhook that's triggered receive a payload? That could be a relatively low-effort way to get the updated content!

Adding Gatsby Cloud as an Integration

For anyone else who may be working on this, adding Gatsby Cloud will look something like this:

Screen Shot 2019-06-20 at 5 07 50 PM

@DSchau
Copy link
Author

DSchau commented Jun 20, 2019

For anyone who works on this, we're happy to give extended trials of Gatsby Preview to best support the necessary work to get this plugin supported. We'd love to see Ghost as a first-class integration!

@aileen aileen added the enhancement New feature or request label Oct 3, 2019
@Kerumen
Copy link

Kerumen commented Dec 15, 2019

Hello everyone,

I've just setup a blog with Ghost and Gatsby and was wondering how to "reload" data from Ghost when deployed in production. As Gatsby is a static site, it must be rebuild each time we update data on Ghost?

This is a huge pain point for blog websites as it's updated very frequently.

Thanks for your answer :)

Edit: OK, I found the official docs for Netlify to trigger rebuilds any time content is updated using webhooks.

aileen pushed a commit that referenced this issue Sep 22, 2020
…61)

closes #42 
refs #44 

At present, `gatsby-source-ghost` uses fake nodes and dummy content to fill in the schema. Using the Gatsby schema customisation API, the schema can be explicitly typed and fully reflect the Ghost API V3 spec. 

Using the dummy nodes method, when changes are made in the Ghost Admin panel to cause the API to return null for a given field, in some cases the schema simply drops the field rather than also returning null (#42). This adds friction to development, builds and is generally confusing to developers who expect the schema to always reflect the Ghost V3 API spec. 

Introducing an explicitly typed schema means developers can make queries without worrying about handling a field that doesn't exist. The action of users in the Ghost admin panel should not halt builds altogether. It would also open up possibilities for schema rebuilding (#44), and might help in getting Ghost to become a first-class integration (#15) with Gatsby.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants