-
-
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
extractPolymorphicRelationship
method is not called when extracting a polymorphic hasMany relationship
#5623
Comments
Seems like an oversight, feel free to PR a fix. |
I wouldn't mind picking this up for Hacktoberfest. I'm assuming it's a case of adding the |
@Parrryy thanks! and yes: https://github.com/emberjs/data/blob/v3.3.1/addon/serializers/json.js#L678 here we would make the same conditional branch as the belongs-to based on whether we are polymorphic. I would recommend caching the check for whether we are polymorphic somewhere outside of the loop. |
…ny (emberjs#5623) Added conditional check to extract polymorphic relationship for hasMany (emberjs#5623) Added extract polymorphic for hasMany relationship
Added check to extract polymorphic relationship for hasMany (#5623)
Why
polymorphic
option is checking only for belongsTo relationships when extracting relationships in DS.JSONSerializer (and in DS.RESTSeriazlizer correspondingly)?I need set proper value for
type
property in relationship hashes for plymorphic hasMany embedded records (in my case I have@odata.type
property in hash and I need to convert it totype
property with appropriate value), otherwise error will be thrown in_normalizeEmbeddedRelationship
method of DS.EmbeddedRecordsMixin when extracting these relationship hashes.My serializers are inherited from DS.RESTSerializer, but I can't use neither
keyForPolymorphicType
hook norextractPolymorphicRelationship
method to specify a custom type key for polymorphic hasMany relationship, because it is called only for belongsTo polymorphic records.So is there a right way to do this? Or what is a right way to customize extracting polymorphic hasMany relationships (some analogue of
extractPolymorphicRelationship
method)?It seems there is no documentation for this case.
The text was updated successfully, but these errors were encountered: