findRecord doesn't assign preload data if record is already in the store
I'm struggling to decide whether this is the desired behavior or not, I can see both arguments. It did however cause me considerable confusion when upgrading. Here is the use case:
- I retrieve a list of items that I find via
store.querywhich does not allow to be preload data onto the models. - I navigate to another route that views the details of the item. On the model hook of this "profile" page I
store.findRecordwith thetype,id, and{preload: {someRelationship: value}}. - When i navigate directly to this route, the preloaded data gets assigned to the model after the promise finished.
- BUT, when i navigate from the previous page, the preload data never gets assigned because it is already in the store i suppose.
It is not a relationship direcly in the model's data, so i have to assign it manually. I could iterate after the query and assign it, but it seems that findRecord should always set the preload data even if the model is already loaded...? That is the struggle. This worked as I expected before I upgraded to new store methods.
I think you are right and that it would be weird to push the new data in. However I'm not sure at all. Probably a good RFC discussion as we were recently considering expanding the ability to preload data with the RecordData RFC.
cc @igorT
@igorT thinks this may have been changed and work now at least for custom model classes but doesn't have a test. We should add a test and provide a fix. The outcome should be that additional preloads are treated as newly pushed (canonical) data and merged onto the existing data.