-
Notifications
You must be signed in to change notification settings - Fork 77
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
Deserializer #210
Comments
You mean take a jsonapi document and hydrate some a model graph? |
@jeregrine probably @denniscastro did mean something like this: # Gemfile
gem 'jsonapi-rails'
# app/controllers/posts_controller.rb
class PostsController < ApplicationController
deserializable_resource :post, only: [:create, :update]
def create_params
params.require(:post).permit(:title, :content, :tag_ids)
end
def create
post = Post.create(create_params)
render jsonapi: post,
include: [:author, comments: [:author]],
fields: { users: [:name, :email] },
status: :created
end
end I would be interested, too, to know if there is a recommended way to accomplish something similar with this package? |
Hi Yes, the deserializer parses the jsonapi params to hash attributes for the model can build his intance. |
https://github.com/vt-elixir/ja_serializer/blob/master/lib/ja_serializer/params.ex has a nice way to deserialize all the attributes and relations. |
OK, that seems pretty interesting. Would you be interested in putting together an issue that proposes a solution? |
This was one thing I missed in past projects when I moved from ja_serializer to jsonapi. I've generally used it as a plug to flatten the incoming params for changeset casting. def parse_data(%{"data" => data}), do: JaSerializer.Params.to_attributes(data) So I like this idea! |
The code can be used as-is. Just add the copyright according to JASerializer license and rename the module to match JSONAPI? |
@jgelens interested in tackling this for Hacktoberfest? |
I have user https://github.com/vt-elixir/ja_resource/ in the past, and found it quite useful. It seems like development on this kind of stopped a year ago or even more. It was a really clever way to build a complete JSONAPI stack. The only thing missing for me was handling submitting objects with child entities all at once, be it through side-posting or breaking the spec and including |
@psteininger we're open to PRs if someone wanted to take a crack at implementing the deserializer functionality for this package 👍 |
@psteininger @denniscastro We do have an |
Upon further thought @denniscastro was this what you were getting at? Effectively taking a jsonapi document and making it easy for changeset casting...(I think this was said a few times :) ) |
Hi,
The Serializer works fine. but I would like to know if there is any plan to implement Deserializer module?, If not, What do you recommend to use for it?
The text was updated successfully, but these errors were encountered: