Welcome to Yoga!

Introduction

Congratulations, you have successfully deployed the Yoga demo!

Yoga extends your existing REST implementation to create nested selectors that provide server-side navigation of the object tree.

This project arose out of real-world issues that were not met by standard REST approaches:

The Yoga approach is simple. On top of your RESTful implementation, you can pass a selector which asks the server to return nested or non-default fields with the response.

For instance, here is a traditional REST request that gets the information for a user:

/user/2.json

A mobile developer can create a very simple profile page with this data. Let's say the designers want to display list of the user's favorite artists on the same profile page. We add the selector as a parameter, like this:

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

You could take this yet a step further, and grab the discography for those artists to display some album information on the same screen:

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

... OR maybe you are more social-graph focused, and you want to show the other users that like the same artists as this person. You could do a circular reference back to the fans of that artist, and print out little icons for each one below the artist, filtering out the user from the profile page itself.

/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".

This approach also works with calls that return collections of resources. Here we retrieve a list of all users in the database, and their favorite artists.

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

Finally, here's an example of a deep-dive query that would take a dozen queries in a traditional RESTful API. It returns a list of all the songs by my friends' favorite artists:

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

Demo

Using the last query above, let's show a race between two simulated mobile clients. They will each try to draw a profile view that shows a user's friends and their favorite artists and corresponding discographies.

The client on the left uses the yoga selector to grab the entire necessary dataset in one query. The client on the right uses traditional object model navigation through multiple requests. To simulate mobile device latency, each response is delayed by 1.5 seconds. Other than that, queries are optimized as much as possible, by running them in parallel.

Yoga - Standby

Friends' Favs for  

Traditional Entity Navigation - Standby

Friends' Favs for  

Get Started!

Ready to look at some code? Head over to the documentation section of our Wiki Page.

Next Steps

Contribute

This is open source so if you want to help out whether by submitting code, design, suggestions, feedback, or feature requests, we appreciate whatever you can contribute. You can contact us at yoga-dev@skyscreamer.org. We'll have proper mailing lists and issue tracking available shortly.