You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I've run in to an issue when working with polymorphic relationships. When using redux-object to build an asset for production, the data type of a polymorphic relationship is lost. There are probably various hacky ways to resolve this... but one clean way is to include an attribute "type" on the build output objects. This would probably be default off but could be turned on with an option control, and it would first check to see if the native object has an attribute or relationship called "type" before attempting to overwrite it. This does means that 'type' becomes special and developers should avoid using 'type' in their model design... but, since we're talking about JSON API spec here, everyone should already be treating it as reserved if they are smart. But, that's why it should be optional.
Do you agree with this? If yes, I'll submit a PR. If no, I'll do it on my own branch. Thanks.
The text was updated successfully, but these errors were encountered:
It will provide a top-level property "type", but there is nothing stopping a designer from having an attribute 'type'. In JSON API spec (and most PHP server-side contexts) these are separate.
redux-object is doing away with that structure and merging everything, so if there is a property 'type' it would normally collide with the record type.
OH HELLO AGAIN.
So, I've run in to an issue when working with polymorphic relationships. When using redux-object to build an asset for production, the data type of a polymorphic relationship is lost. There are probably various hacky ways to resolve this... but one clean way is to include an attribute "type" on the build output objects. This would probably be default off but could be turned on with an option control, and it would first check to see if the native object has an attribute or relationship called "type" before attempting to overwrite it. This does means that 'type' becomes special and developers should avoid using 'type' in their model design... but, since we're talking about JSON API spec here, everyone should already be treating it as reserved if they are smart. But, that's why it should be optional.
Do you agree with this? If yes, I'll submit a PR. If no, I'll do it on my own branch. Thanks.
The text was updated successfully, but these errors were encountered: