Obtaining a single event
Story
As an application user I want to display details of a single event So I can find out more about an event I'm interested in.
As an API consumer I want to be able to retrieve a single resource So that I can explore it details.
Usage
const event = hydraClient.getResource("http://example.com/api/events/1");
// do something with the _event_, i.e. display it in a details view
Details
After displaying all the events in a calendar, user should be able to browse details of a selected event. It wouldn't be possible for the calendar to show all of the event's attributes, thus there is a need to show those outstanding ones in a separate view (i.e. popup, new screen, etc.). The application sends a GET request to the selected event's resource identifier:
GET /api/events/1
HTTP 200 OK
{
"@context": "/api/context.jsonld",
"@id": "/api/events/1",
"@type": "schema:Event",
"eventName": "Event 1",
"eventDescription": "Some event 1",
"startDate": "2017-04-19",
"endDate": "2017-04-19"
}
Now the user can see what a given event was about.
Considerations
Including related resources
Assuming that the application knows what kind of resource will be returned, it could try to express what kind of details it would like to receive. This is due to fact that again, the application is unsure what will come - whole resource, properties with literal values only, or some other subset. Including (or excluding) those additional details would be extremely useful for obtaining related resources, i.e. in case of an event application might want to expand attendees (or at least some of their details). This way some optimizations can be achieved when a single request obtains details that feed more than a single screen which may improve user experience.
Projection
Another interesting feature would be a possibility of projecting a resource. It is a common situation when an application shows an edit form for a given resource - in order to assign a value to the i.e. event's attendee property, some kind of UI element should be presented (let's say a search-as-you-type like input) which would display projected resources - concatenation of the first and last name.
The issue here is that the syntax for such a feature would make the spec incredibly complex.