The API returns a different set of fields of an object depending on as context
& _fields
parameters. One option we have to deal with this is to have every field of an object be optional. However, that would require the clients to spend extra time to deal with nullability of each field. It's also against our design goals, as we want to keep everything strongly typed as much as possible.
In order to have strongly typed objects while still supporting every scenario of context
& _fields
parameters, we would like to write a macro to generate different versions of an object. For example, for a UserObject
, we might have UserViewObject
, UserEditObject
etc.
We'll still need one object with all its fields being optional, because with _fields
parameter, any field might be omitted. However, we want to limit the usage of this object type.
We also need to have separate parsers for each context type.