-
Notifications
You must be signed in to change notification settings - Fork 148
Description
While buiding #32, I took a deep dive into the relationships and how the different options relate to one another. I discovered a handful of issues, mostly around the lack of clarity of how all the options relate to one another.
Here are some examples. In these cases, can anyone tell me with certainty what should happen? Which serializer is used? What is the type outputted in the relationships hash? What is the type outputted in the included hash?
belongs_to :account
has_many :accounts
belongs_to :account, record_type: :employee_account
belongs_to :account, serializer: :employee_account
belongs_to :account, record_type: :user_account, serializer: :employee_account
belongs_to :account, serializer: EmployeeAccountSerializer
belongs_to :account, polymorphic: true
belongs_to :account, polymorphic: true, record_type: :employee_accountOther questions:
-
What happens if the relationship defines a
record_typethat is different from what is defined by the serializer'sset_type? Does it output two different types? Does one take precedence over the other? -
What happens if the
id_method_nameis defined on the relationship? How does it relate to theset_idmethod of the serializer? Do they conflict with one another if they are both set differently? Does one take precedence over the other?
I honestly don't think anyone can say with certainty how all of these scenarios actually work. And I think the actual results would be surprising. This is partly because there is some overlap in the API, and partly because we don't have the specs that describe the behavior in a concise way. We have some good test coverage, just not very specific, isolated, targeted tests to describe this behavior, to make sure it works as designed, and to prevent future changes from breaking the behavior.
Doing this exercise will also help us to identify areas of overlap and help refine the API.
I can take a shot at this after #32 is merged. That PR implements a couple changes / bug fixes to the record_type behavior. Without it, we would have several tests failing until it is merged.