datocms / product-roadmap

This project is now discontinued. For feature requests, please use our community forum.
https://community.datocms.com/
19 stars 1 forks source link

Include alphanumeric model IDs in Webhook payloads and Content Delivery API payloads #174

Open jacob-tiu opened 5 years ago

jacob-tiu commented 5 years ago

Is your feature request related to a problem? Please describe. When processing webhook updates from the Content Delivery API, the alphanumeric model IDs (e.g. 'article') are not included, so we don't know which models are involved without cross-referencing itemTypes for the models manually. Writing business logic against itemType IDs is painful and not scalable because we don't know what they are by looking at them.

Describe the solution you'd like Include the alphanumeric model ID (aka ItemType.attributes.api_key) in the Content Management API payloads) in the in both webhook payloads and Content Delivery API responses. Mocked webhook payload below, note the addition of relationships.item_type.key

Describe alternatives you've considered The workaround requires us to grab a list of all models from the Content Management API, cache it on our own server for fast lookups, then cross-reference that in order to process webhook updates. Then create a webhook processor to watch for model changes in order to invalidate our cache of the model list.

Additional context

{
  "entity_type": "item",
  "event_type": "update",
  "entity": {
    "id": "1272501",
    "type": "item",
    "attributes": {
      "slug": "test1",
      "header1": "test",
      "header2": "Hello",
      "body": "Blah blah",
    },
    "relationships": {
      "item_type": {
        "data": {
          "id": "115919",
          "type": "item_type"
          "key": "article"
        }
      },
      "creator": {
        "data": {
          "id": "24999",
          "type": "access_token"
        }
      }
    },
    "meta": {
      "created_at": "2019-07-20T14:37:56.951-07:00",
      "updated_at": "2019-07-22T19:54:03.680-07:00",
      "published_at": "2019-07-22T19:54:03.680-07:00",
      "publication_scheduled_at": null,
      "first_published_at": "2019-07-20T14:37:56.967-07:00",
      "is_valid": true,
      "status": "published",
      "current_version": "2433169"
    }
  }
}
matjack1 commented 4 years ago

This feature request has been moved to https://community.datocms.com/t/241