Is my usage of nested relationships is right?


#1

I have found similar topic ( Is it ok to add multiple levels of nested relationships in the relationships field ) but missing part where I should put all includes it self from nested resources.

Please see example and suggest is it a valid way to represent such resources:

{
  "data": {
    "type": "category",
    "id": "5715e6649a892006ae7224f7",
    "attributes": {
      "name": "Category name"
    },
    "relationships": {
      "article": {
        "data": {
          "type": "article",
          "id": "56fab7f59a8920070e34bec8"
        }
      }
    }
  },
  "included": [
    {
      "type": "article",
      "id": "56fab7f59a8920070e34bec8",
      "attributes": {
        "name": "Article name"
      },
      "relationships": {
        "author": {
          "data": {
            "type": "author",
            "id": "56f90cf59a8920070e34bec7"
          }
        },
        "editor": {
          "data": {
            "type": "editor",
            "id": "56f93a469a8920070d466517"
          }
        }
      }
    },
    {
      "type": "author",
      "id": "56f90cf59a8920070e34bec7",
      "attributes": {
        "name": "MyName"
      }
    },
    {
      "type": "editor",
      "id": "56f93a469a8920070d466517",
      "attributes": {
        "name": "MyName"
      }
    }
  ]
}

Thanks!


#2

Yes, the way you’ve done it is perfect


#3

Thank you for taking a look!