-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
polymorphic docs don't mention how to find/fetch polymorphic #5246
Comments
Agreed -- they're also unclear on whether you have to do anything special with JSONAPI:
I can't make head or tail of this sentence. Do I somehow have to mark types polymorphic with JSONAPI, or it enough that they just have a particular relationship? |
Yeah that sentence is pretty awful :( Roughly speaking, always give the most specific type possible to any resource your API returns. For instance, if |
My serializer needs the following code for my polymorphic relationship serialize(snapshot, options) {
let result = this._super(...arguments);
let props = snapshot.hasMany('props');
if(props) {
result.props = props.map(prop => ({
id: prop.id,
type: prop.modelName,
}));
}
return result;
}, Loading using |
We're working on some big improvements to polymorphism that were unlocked by the relationship-refactor work and the identifiers work. The intent is to RFC an official polymorphism feature (polymorphism has mostly been undocumented because it never was fully designed) and we'll be sure to add a polymorphic guide at that time. Until then, I'll see if we can get some small docs updates done to illuminate how the current setup works. |
Explicit relationship polymorphism is now in place, polymorphic find was described by the identifiers RFC (though showing a basic config in the guides would be nice too). Polymorphic find is also covered by the RequestManager, since it is agnostic to type. Broadly speaking, most things in EmberData are agnostic to type at this point, most polymorphic cases should "just work" excepting those in which you refer to the same resource by multiple identities, in which case you will need to configure the IdentifiersCache to be able to know that these identities refer to the same resource. Closing in favor of the documentation quest in #8394 |
Would expect to see how to find/fetch exactly
my-model
ormy-model and all its descendants
.The text was updated successfully, but these errors were encountered: