Open mptr opened 2 years ago
Hello @mptr,
I am not sure on this. When would you need this?
Lets assume I use class-transformer to build Views for my REST-API. With the proposed mechanism i am able to use excludeAll as a default strategy for my views and am able to override it for nested fields if explicitly specified. For example my User class sould be excludeAll (exposes only explicitly annotated Fields) but associated Objects (for example Instances of "Post" class with the User as author) could be served using exposeAll which then does not require all Properties to be annotated.
I do think this as a low priority feature, so I do not think this will be implemented. Your "hacky" workaround seems to be good.
Description
I would appreciate a feature that lets you switch the default expose-strategy for nested Objects.
Proposed solution
I'd like to define my Classes like:
instanceToPlain
-transform something like:{ pAttr: 3, child: { cAttr: 7 } }
{ child: { cAttr: 7 } }
cAttr is visible because Strategy changed by decoator
The only dirty hack I found for this was to change the strategy by:
but this will change the strategy not just for nested but for all following transformations, even in parent and so on.
Is there a not-so-hacky workarround for the time being?