vendredi 13 novembre 2015

How do you handle large relationship data attributes and compound documents?

If an article has several comments (think thousands over time). Should data.relationships.comments return with a limit?

{
  "data": [
    {
      "type": "articles",
      "id": 1,
      "attributes": {
        "title": "Some title",
      },
      "relationships": {
        "comments": {
          "links": {
            "related": "http://ift.tt/1iYZr6P"
          },
          "data": [
            { "type": "comment", "id": "1" }
            ...
            { "type": "comment", "id": "2000" }
          ]
        }
      }
    }
  ],
  "included": [
    {
      "type": "comments",
      "id": 1,
      "attributes": {
        "body": "Lorem ipusm",
      }
    },
    .....
    {
      "type": "comments",
      "id": 2000,
      "attributes": {
        "body": "Lorem ipusm",
      }
    },
  ]
}

This starts to feel concerning, when you think of compound documents (http://ift.tt/1ECm4Zl). Which means, the included section will list all comments as well, making the JSON payload quite large.

Aucun commentaire:

Enregistrer un commentaire