Open
Description
Hi guys,
Currently, code that parse responses and generate payloads for requests spread out between two components JsonApiDatastore
and JsonApiModel
. This cause unnecessary complexity of each component and high coupling between them. Code is a bit messy and it hard to test it. Also it's not flexible because end user couldn't change any parts of data handling process.
I think that we should refactor this code to series of separate components - serializers. We should have three types of serializers:
ResponseSerializer
- it should be able to convert response data toDocumentModel
(see Support for more general json:api documents (links, data, meta) #26). Under hood it should use models serializers (see below) to convert separate resources.RequestSerializer
- it should be able to convert specifiedJsonApiModel
to request payload. Again, under hood it should use models serializers to convert separate resource.ModelSerializer
- it should support two things: unserialize part of response data toJsonApiModel
instance and serializeJsonApiModel
instance into part of request payload.
All serializers should be configurable. I.e. we need to support following scenarios:
- user should be able to replace default response, request and model serializers
- user should be able to use cumstom serializer for specific
JsonApiModel
Please let me know what you think about it.