datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 50 forks source link

Implement incremental data updates #108

Closed sidharthachatterjee closed 4 years ago

sidharthachatterjee commented 4 years ago

The changes in this PR enable this plugin to use Gatsby's refresh endpoint to incrementally source nodes. This requires webhooks from Dato to be set since the plugin now uses the metadata passed in to fetch new data. The required webhook settings are

Triggers

Entity: Record Events: Publish, Unpublish

Entity: Asset Events: Create, Update, Delete

Entity: Model Events: Create, Update, Delete

HTTP Body

Send a custom payload? :white_check_mark:

{
  "event_type": "{{event_type}}",
  "entity_id": "{{#entity}}{{id}}{{/entity}}",
  "entity_type": "{{entity_type}}"
}

(These are now the default in the auto provision for Gatsby Cloud)

matjack1 commented 4 years ago

Thank you! I'm going to merge with this PR: https://github.com/datocms/gatsby-source-datocms/pull/110 as this need some rebasing first :)