I'm trying to figure out how to compose FB Graph API requests (FB SDK 4.0 and Swift) when the second (child) request is dependent on the first (parent) request. Specifically I would like to get a user's albums and each album's cover photo.
me/albums?fields=name,cover_photo <-- Get user albums request
/888474748 <-- Get cover photo request
The documentation is very vague regarding this and API docs for FBSDKGraphRequestConnection mention that method addRequest:completionHandler:batchParameters: can accept parameters such as "name" and "depends_on". This appears to be the method I'm looking for but I can find an example of its use in Obj-C or Swift.
Should it look something like this? Thanks!
let albumRequest = FBSDKGraphRequest(graphPath: "me/albums?fields=name,cover_photo", parameters: nil)
let albumCoverRequest = FBSDKGraphRequest(graphPath: "cover_photo_id", parameters: nil) //what should this look like? jsonpath?
let graphConnection = FBSDKGraphRequestConnection()
graphConnection.addRequest(albumRequest, completionHandler: { (connection:FBSDKGraphRequestConnection!, result:AnyObject!, error:NSError!) -> Void in
if(error != nil){
println(error)
}else{
}
},batchParameters: ["name" : "albums"])
graphConnection.addRequest(albumRequest, completionHandler: { (connection:FBSDKGraphRequestConnection!, result:AnyObject!, error:NSError!) -> Void in
if(error != nil){
println(error)
}else{
}
},batchParameters: ["depends_on" : "albums"]) //should this be some jsonpath expression?