Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adds support for included and custom deserializers #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

broosk1993
Copy link

@broosk1993 broosk1993 commented Feb 13, 2023

Currently, jsonapi-deserializable only adds [relationship]_id and [relationship]_type to the final deserialized object.

This PR enables attaching the nested document from the included section to the relationship.

Additionally, this PR adds the followings:

  1. Adding the document(s) from the included section of the payload is opt-in. You can enable it by adding the option with_included: true to the relationship.
  2. Support for both has_one and has_many
  3. Support for deserialization using a custom Deserializer for each relationship by passing the deserializer: option to the relationship.
  4. Support for deserializing a property whose type is not the same as the property's name through the type: option.
  5. Only supports first-level included if no deserializer: option is provided, but can support as many levels of included if the option is given.
  6. It is backward-compatible and does not introduce breaking changes to existing code bases that use it.

See README.md for more examples

@beauby
Copy link
Member

beauby commented Feb 23, 2023

Thanks for the PR! I'll leave the decision to @remear, but in the meantime here is one remark about your third point ("Support for deserialization using a custom Deserializer for each relationship by passing the deserializer: option to the relationship."): opening the way to conflicts is not great (i.e. ending up with one resource having multiple valid deserializers), and I'd see a map from type to deserializer being used to select/customize deserializers.

@brodyhoskins
Copy link

My team would appreciate support for Compound Documents. @broosk1993, have you looked into the concerns brought up?

@broosk1993
Copy link
Author

My team would appreciate support for Compound Documents. @broosk1993, have you looked into the concerns brought up?

Thank you so much @brodyhoskins. I haven't had time to address the concerns. I will try to look into them. My team will also be happy to cooperate. Let me know how you like to move forward.

@brodyhoskins
Copy link

@broosk1993 I'm not a maintainer unfortunately; I was only curious if you'd simply missed the comment earlier.

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

Successfully merging this pull request may close these issues.

3 participants