DS.JSONAPIAdapter#coalesceFindRequests

coalesceFindRequests{boolean}

Inherited from DS.RESTAdapter but overwritten in addon/adapters/json-api.js:63

By default the JSONAPIAdapter will send each find request coming from a store.find or from accessing a relationship separately to the server. If your server supports passing ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests within a single runloop.

For example, if you have an initial payload of:

{
  post: {
    id: 1,
    comments: [1, 2]
  }
}

By default calling post.get('comments') will trigger the following requests(assuming the comments haven't been loaded before):

GET /comments/1
GET /comments/2

If you set coalesceFindRequests to true it will instead trigger the following request:

GET /comments?filter[id]=1,2

Setting coalesceFindRequests to true also works for store.find requests and belongsTo relationships accessed within the same runloop. If you set coalesceFindRequests: true

store.findRecord('comment', 1);
store.findRecord('comment', 2);

will also send a request to: GET /comments?filter[id]=1,2

Note: Requests coalescing rely on URL building strategy. So if you override buildURL in your app groupRecordsForFindMany more likely should be overridden as well in order for coalescing to work.

doc_EmberJs
2016-11-30 16:49:40
Comments
Leave a Comment

Please login to continue.