Skip to content

Commit

Permalink
Add debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Ybrin committed May 10, 2017
1 parent f30377b commit 9db7375
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/VaporJsonApi/Resources/JsonApiResourceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,30 @@ public extension JsonApiResourceController {
throw JsonApiRecordNotFoundError(id: id)
}

print(id)
print(relationshipType)
print(try resource.parentRelationships().debugDescription)
print(try resource.parentRelationships()[relationshipType] ?? "Nothing!?")

let query = req.jsonApiQuery()

if let parentModel = try resource.parentRelationships()[relationshipType] {
print("PARENT***")
if let parent = try parentModel.getter().get() {
let resourceObject = try parent.makeResourceObject(resourceModel: parent, baseUrl: req.uri)
let data = JsonApiData(resourceObject: resourceObject)
let document = JsonApiDocument(data: data)

print("UPPER***")

return JsonApiResponse(status: .ok, document: document)
} else {
print("LOWER***")
let document = JsonApiDocument()
return JsonApiResponse(status: .ok, document: document)
}
} else if let childrenCollection = try resource.childrenRelationships()[relationshipType] {
print("CHILDREN***")
let children = try childrenCollection.getter()

let page = try pageForQuery(query: query)
Expand All @@ -117,6 +127,7 @@ public extension JsonApiResourceController {
return JsonApiResponse(status: .ok, document: jsonDocument)
} else if let siblingsCollection = try resource.siblingsRelationships()[relationshipType] {
let siblings = try siblingsCollection.getter()
print("SIBLINGS***")

let page = try pageForQuery(query: query)
let pageNumber = page.pageNumber
Expand Down

0 comments on commit 9db7375

Please sign in to comment.