mercredi 31 août 2016

Stop pushPayload from triggering automatic fetches

I'm currently manually pushing some data upon initialization of my Ember app using pushPayload. I'm using JSONAPI as the adapter.

When I push it the data (which loads correctly) it contains relationship references to other records that are not yet loaded (or may never load depending on how the user interacts with the page).

If Ember sees something like

{ 
   id: 1,
   type: 'project',
   relationships: 
     jobs: {
       data: [
         { id: [some_id_not_yet_loaded], type: 'job' }, 
         { id: [another_id_not_yet_loaded], type: 'job' }, 
       ]
     },
}

It then is automatically querying /jobs/filter[id]=1,2,..x. It's both unnecessary/not performant to issue this request. I realize this is part of the Ember Data default behavior but I'd like to be able to override it such that the Ember store will still maintain the references to both jobs but only hydrate them when the corresponding project is loaded (or not).




Aucun commentaire:

Enregistrer un commentaire