Yoga

a Skyscreamer open source project


Cookbook

First, play with the selector builder. Access the builder by replacing the suffix for any RESTful call with .yoga. Try it out:

/user/1.yoga

Here's various examples:

A traditional REST request:

/user/2.json

A user and his favorite artists:

/user/2.json?selector=favoriteArtists

Same as above, but also get the artists albums:

/user/2.json?selector=favoriteArtists(albums)

Find other people who like the same bands:

/user/2.json?selector=favoriteArtists(fans)

Note that the circular reference does not continue to loop, since a selector has not been added to "fans".

You can also apply a selector to calls that return collections. All artists and their albums:

/artist.json?selector=albums

This would take hundreds of queries with typical REST calls. Show songs by your friends' favorite artists:

/user/1.json?selector=friends(favoriteArtists(albums(songs)))

Yoga creates a lot of flexibility for the client. All of these selectors are completely dynamic. As long as the fields are in the object map, Yoga will find them..