wvteijlingen / Spine

A Swift library for working with JSON:API APIs. It supports mapping to custom model classes, fetching, advanced querying, linking and persisting.
MIT License
264 stars 109 forks source link

Access relationship "data" field #136

Open alanwguo opened 7 years ago

alanwguo commented 7 years ago

If the API response returns relationship with data without sideloading the related resource, is there a way to access that data with Spine?

With the following response:

{
  data: {
    type: "foo",
    id: "asd",
    relationships: {
      bar: {
        data: {
          type: "bars",
          id: "barId"
       }
    }
  }
} 

Is there a way for to access barId from my foo resource object? I see there is a relationships array within Resource but that is not publicly accessible and its not really an ideal API to search an array to get the correct relationship data.

markst commented 7 years ago

@alingrad I think this is similar question to what I had: https://github.com/wvteijlingen/Spine/issues/127