2
votes

I'm trying to handle a JSONAPI response with nested relationships. Ember-Data is currently picking up all of the data in the 'included' property and pushing it all into the correct models, but the relationships between my 'transcription' objects and 'cuepoint' objects aren't working. The relationship between 'video' and 'transcription' objects is working correctly, so it's specifically the nesting portion that I need help with.

Here's an example of the data I'm using:

{
   "data":{
      "type":"video",
      "id":"55e0687ba1f9e8032c549680",
      "attributes":{
         "title":"Test32"
      },
      "relationships":{
         "transcriptions":{
            "data":[
               {
                  "relationships":{
                     "cuepoints":{
                        "data":[
                           {
                              "id":"55e9b62446942224a0f456cc",
                              "type":"cuepoint"
                           }
                        ]
                     }
                  },
                  "id":"55e0687ba1f9e8032c549680-transcription-0",
                  "type":"transcription"
               }
            ]
         }
      }
   },
   "included":[
        {
           "type":"transcription",
           "id":"55e0687ba1f9e8032c549680-transcription-0",
           "attributes":{
              "language":"English"
           }
        },
      {
         "type":"cuepoint",
         "id":"55e9b62446942224a0f456cc",
         "attributes":{
            "cueIndex":0,
            "startTimeMilliseconds":0,
            "endTimeMilliseconds":4400,
            "text":"- The first one is the L'Oreal Paris Extraordinary Oil."
         }
      }
   ]
}

Any idea how I can handle this?

1

1 Answers

2
votes

While I haven't tested this particular case, your JSON appears not compliant.

Under the top-level relationships key, you place "relationship" objects, and in included you place "resource" objects. Resource objects contain relationship definitions.

In short, move the nested relationships outside of the top-level relationships and into included.