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 #175

Closed jacob-tiu closed 5 years ago

jacob-tiu commented 5 years ago

Is your feature request related to a problem? Please describe. When processing webhook payloads, the alphanumeric model IDs are not included so we're forced to try and cross-reference numeric itemType IDs manually. We need to write business logic on our side for these and it's painful because we have to maintain our own list of models in order to cross-reference. Hard-coding numeric IDs into our business logic is a dead-end. We should always have the alphanumeric model IDs available in response payloads.

Describe the solution you'd like Include the alphanumeric model IDs in webhook payloads. Mocked webhook payload below. Note: the addition of relationships.item_type.key

Describe alternatives you've considered We are having to grab a list of all models from the Content Management API and cache it on our server in order to have a list of models to cross-reference the itemType IDs against. Writing business logic against the numeric itemType IDs is painful and not scalable. In order to keep our list up to date, we have to have a second webhook listener to watch for model changes and invalidate our cache.

Additional context

{
  "entity_type": "item",
  "event_type": "update",
  "entity": {
    "id": "1272501",
    "type": "item",
    "attributes": {
      "slug": "intro3-default",
      "header1": "test",
      "header2": "Hundreds of...",
      "image_url": {
        "path": "image.jpg",
        "format": "jpeg",
        "size": 176815,
        "alt": null,
        "title": null,
        "width": 808,
        "height": 1768
      },
      "video_key": "",
      "button_label": "",
      "button2_label": "",
      "db_id": 4,
      "updated_at": "2019-07-22T19:54:03.680-07:00",
      "created_at": "2019-07-20T14:37:56.951-07:00"
    },
    "relationships": {
      "item_type": {
        "data": {
          "id": "115919",
          "key": "article"
          "type": "item_type"
        }
      },
      "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 5 years ago

Duplicate of #174