I have come across this answer which makes reference to Hypermedia. My question is similar.
I am writing a REST API that will be predominantly consumed by mobile devices. For this reason I want to try and keep a handle on efficient network I/O.
Say for example I have a Book object that contains a TableOfContents (collection) property. In my app I want to display a list of all books to the user. Then when a user selects a book I want to show them the table of contents.
Now, when requesting the list of books I am only interested in say, the Title and thumbnail, because nothing else is display in the list view item. I only want to pull down other items as the books are selected. This is because most probably, not all books will be selected. And so on..
Some possible solutions to a lazy loading approach:
- Have two object types. BookLight and Book. BookLight only has title and thumbnail. Book has everything. This is not lazy loading and seems like a crap approach.
- One object which the Rest API will return all fields for, unless there is a query in the request which states which fields are required, and not to return any others. Then, when the object is selected and the full object is required a new query is made with the remaining fields. Alternatively, leave the query blank to refresh the entire object.
Any thoughts?