Better record polymorphism#67
Conversation
|
It seems like people like the alternative better, I will update the RFC |
|
Having tried to use polymorphic models before (eventually dropping them because they weren't working the way we needed), I feel that the alternative proposal is not necessarily any simpler or clearer for developers. I also agree with the drawbacks being a big enough issue to not go with the alternative, and prefer the rfc proposal instead. |
|
I like the first approach, it's explicit and clear. |
|
Any update on this? I agree with @trabus and @knownasilya on this one. In the drawbacks, you mentioned that if the
return
|
|
Have we given this any more thought. I like the second approach as it closely mirrors how our backend models work. It will provide consistent results with no code changes to the calls that are previously out there. And in my experience if you have a polymorphic model you are most likely calling the sub class models in finds because you can't call the parent and get all the models you'd expect back. This would greatly simplify some of our code if we could just pull the trigger on this |
|
I'd be glad to have either of the approaches working. Any news on this? |
|
Progress? |
|
Will the ids-and-type strategy in upcoming ember-data 2.6 lay parts of the groundwork for this? |
|
@leifcr I doubt it. That feature is basically a polymorphic relationship extension. It was motivated by the fact that an id isn't enough to uniquely identify an object. |
|
Something like that is desperately needed to avoid horrible workaround. As is, I hope support for something like this will be implemented soon. |
|
hey @igorT is there something we can do to help move this forward? We hit this problem and are having issues handling some polymorphic relationships. If you give us some guidance, we could take a stab at implementing it with @sescobb27 & @NicolleJimenez |
|
I've got an interest in this as well. We built our own addon but it uses private api that's broken in ED 2.10. What's the current state? @buritica I'm also available to help |
|
Added a proposal for automatic hierarchy discovery, including code that we use in our ED 2.8.0 addon |
|
We could improve the "refactor hostile" drawback of the |
|
@courajs sounds good. Default should definitely be polymorphic. Should be able to turn the warning off, otherwise it will flood a real polymorphic app. |
|
3 years since the original issue is there any progress? I'm using an addon to fake some of it but it uses private API so is tied to 2.10. 2.10 stops me upgrading ember to use glimmer as pushPayload is broken with later ember. I'm. |
@BryanCrotaz, do you think your addon might make a good starting point to implement this RFC? If it's available on github, I'd love to take a look. My team has been maintaining some custom adapter/serializer code in our app to essentially handle what this RFC proposes but I'd love to use and contribute to a community solution instead. |
|
Not sure if https://github.com/EmberMap/ember-data-storefront would be a good place for this, worth checking there too. |
|
I suspect now that Ember has true class inheritance that this is something we could support more easily and would be nice to revisit. |
|
I think we have a much simpler path to polymorphism for everything except findAll
|
|
@runspired Not sure my use case is related, but I would something like 'lazy load' records coming from an async polymorphic hasMany, one at a time, to be able to put placeholders while each record is loading. |
|
@runspired do you think this RFC can be revived? or does it make more sense to write a new one? |
|
@wagenet probably best as a new RFC |
|
@runspired I'll go ahead and close. If you need a tracking issue will you be able to take care of that? |
https://github.com/emberjs/rfcs/blob/polymorphism/text/0000-find-polymorphism.md