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

syntax sugar render like other serializers #408

Open
yoshi12u opened this issue Apr 12, 2019 · 2 comments
Open

syntax sugar render like other serializers #408

yoshi12u opened this issue Apr 12, 2019 · 2 comments

Comments

@yoshi12u
Copy link

yoshi12u commented Apr 12, 2019

Hi team!
I suppose almost everyone use new and serialized_json at the same time, so I suggest that FastJsonapi::ObjectSerializer should have render, which is syntax sugar of .new(args).serialized_json.
A situation when tihs feature would be useful is, for example, when you want to serialize a poro with other serializer(e.g. serialize pagy with blueprinter to generate a json of pagination links). If FastJsonapi has render, we can use any serializer with polymorphism because serializers recommended in the README.md of active_model_serializers, such as blueprinter and jsonapi-rb , have render to serialize objects.

@zion
Copy link

zion commented Apr 16, 2019

this would be great!

@stas
Copy link
Contributor

stas commented Jul 1, 2019

To some extend, this is related to the #175 and #102 and I would argue how generic a render method can be in the context of a generic serialization library.

Just some of reasons why this might be very much framework implementation specific:

  • content type handling
  • pagination (as already mentioned)
  • resource vs. error serialization
  • single vs. collection serialization
  • serializer params/args DRY handling

As I mentioned before, it's up to the fast_jsonapi team to decide how generic the library should be. In the meantime consider taking a look at stas/jsonapi.rb gem which does this for you.

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

3 participants