Skip to content
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

Suggestion: Optionally include 'type' attribute in results #16

Closed
GregPeden opened this issue Jul 8, 2017 · 2 comments
Closed

Suggestion: Optionally include 'type' attribute in results #16

GregPeden opened this issue Jul 8, 2017 · 2 comments

Comments

@GregPeden
Copy link
Contributor

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.

@yury-dymov
Copy link
Owner

Well, type field comes by default from json api spec.

I don't see any issues with your PR, so I am going to merge it with pleasure. Thank you for your work!

@GregPeden
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants