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

Cannot use JSON DS.RESTSerializer to serialize outgoing data and HAL serializer for incoming data #37

Closed
cristinawithout opened this issue Dec 8, 2015 · 1 comment

Comments

@cristinawithout
Copy link
Contributor

This is somewhat related to #31 as it relates to output format, but I've opened a new issue as that one appears to deal mostly with wanting to serialize into HAL JSON format and the solution is to extend the HAL serializer and implement a serialize method.

What I need is to serialize into the format of DS.RESTSerializer and normalize using the HAL serializer. This was the default behavior of this addon's HAL serializer in 0.1.6 when it extended DS.ActiveModelSerializer. We're upgrading apps that were made using that version of this addon.

I could of course extend the HAL serializer and implement the serialize method to do the exact same thing as DS.RESTSerializer. But that seems very sloppy, and I hate to duplicate code.

What I'd like is to have the HAL serializer functionality as mixin. Then I can extend DS.RESTSerializer with the HAL mixin. This addon's HAL serializer can still extend DS.JSONAPISerializer and use the HAL mixin as well. Or the addon itself could provide serializers that extend Ember Data's provided serializers. (DS.JSONSerializer and DS.RESTSerializer).

Without a HAL mixin in this addon, the only solution to serialize data using the JSON or REST serializer is to not use this addon and instead copy the contents of its serializer, which I don't like almost as much as duplicating the serialize method of DS.RESTSerializer.

Would this be something you'd consider?

(Note that we intend to change to JSON API, but our server framework, Apigility, doesn't yet support JSON API. So that won't happen in the immediate future.)

@bantic
Copy link
Member

bantic commented Oct 12, 2016

Thanks for opening this issue and for making the PR!
Closed by #38

@bantic bantic closed this as completed Oct 12, 2016
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