We're working on a charting application that, for performance reasons, needs a way to split the chart data from some meta data to render charts to select from.
It doesn't appear that Ember-data (currently v2.5.0) supports JSONAPI's Sparse Fieldsets. Does it?
There are probably other options, like using relationships, but the design that's most intuitive to us right now is to break the spec and use different endpoints for when a chart is queried in a collection:
GET ../charts/
{"data": [{
"type": "charts",
"id": "1",
"attributes": {
"type": "A",
"precision": "10",
"average": "22.2",
"minimum": "20.4",
"maximum": "25.3",
},
{
"type": "charts",
"id": "2",
"attributes": {
"type": "A",
"precision": "100",
"average": "20.0",
"minimum": "10.0",
"maximum": "30.0",
},
...
]}
and properly when queried by ID:
GET ../charts/1
{"data": {
"type": "charts",
"id": "1",
"attributes": {
"type": "A",
"precision": "10",
"average": "22.2",
"minimum": "20.4",
"maximum": "25.3",
"history": [
["100","21.0"],
["200","20.4"],
["300","25.3"],
...
]
}
}
But we haven't found a way to force EmberData to reload the data from the backend service from a Component. We'd like to use the backgroundReload functionality, as we believe that would provide the best visual results, but all documentation about it is done using model hooks from a Route.
Am I on the right track or has someone solved this?
A note of caution for future Googlers -- this is not using actual JSONapi Sparse Fieldsets with fields[chart]=history
but is just relying on breaking the JSONapi spec and returning different attributes for each endpoint.