Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Querying nested relationships doesn't use relationships link URL #178

Open
bparise opened this issue Apr 17, 2017 · 0 comments
Open

Querying nested relationships doesn't use relationships link URL #178

bparise opened this issue Apr 17, 2017 · 0 comments

Comments

@bparise
Copy link

bparise commented Apr 17, 2017

I am trying to traverse nested relationships and when Query with resourceCollection, the URL being generated is not the one as defined in the relationship:

{
  "data": [
    {
      "type": "universities",
      "id": "1",
      "attributes": {
        "name": "Test University"
      },
      "relationships": {
        "organizations": {
          "data": [
            {
              "type": "organizations",
              "id": "1"
            },
            {
              "type": "organizations",
              "id": "2"
            }
          ],
          "links": {
            "self": "/universities/1/relationships/organizations"
          }
        }
      }
    }
  ]
}
func testNested() {
  spine.findAll(University.self).onSuccess { collection, meta, jsonapi in
      for university in collection.resources as! [University] {

          // This attempts to load GET /organizations (which is wrong)
          let query = Query(resourceType: Organization.self, resourceCollection: university.organizations!)

          // This attempts to load GET /universities/1/relationships/organizations (which is right)
          let query = Query(resourceType: Organization.self, path: (university.organizations?.linkURL?.relativeString)!)
      }
  }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant